X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffserver.c;h=1d4c8dc5b98453f2cc158ac73e3077e804195efc;hb=78d9658a4d04bb4c281b49cdf8c2ef8b4090ed44;hp=f9e40b54fd6ab5ff893f7e58cf43bc45286f51b5;hpb=25a7c2aed6f4eec05c771e047f418e31610170c7;p=ffmpeg diff --git a/ffserver.c b/ffserver.c index f9e40b54fd6..1d4c8dc5b98 100644 --- a/ffserver.c +++ b/ffserver.c @@ -71,6 +71,8 @@ #include "cmdutils.h" #include "ffserver_config.h" +#define PATH_LENGTH 1024 + const char program_name[] = "ffserver"; const int program_birth_year = 2000; @@ -285,10 +287,14 @@ static int ffm_write_write_index(int fd, int64_t pos) for(i=0;i<8;i++) buf[i] = (pos >> (56 - i * 8)) & 0xff; if (lseek(fd, 8, SEEK_SET) < 0) - return AVERROR(EIO); + goto bail_eio; if (write(fd, buf, 8) != 8) - return AVERROR(EIO); + goto bail_eio; + return 8; + +bail_eio: + return AVERROR(EIO); } static void ffm_set_write_index(AVFormatContext *s, int64_t pos, @@ -388,16 +394,33 @@ static int compute_datarate(DataRateData *drd, int64_t count) static void start_children(FFServerStream *feed) { - char pathname[1024]; + char *pathname; char *slash; int i; + size_t cmd_length; if (no_launch) return; + cmd_length = strlen(my_program_name); + + /** + * FIXME: WIP Safeguard. Remove after clearing all harcoded + * '1024' path lengths + */ + if (cmd_length > PATH_LENGTH - 1) { + http_log("Could not start children. Command line: '%s' exceeds " + "path length limit (%d)\n", my_program_name, PATH_LENGTH); + return; + } + + pathname = av_strdup (my_program_name); + if (!pathname) { + http_log("Could not allocate memory for children cmd line\n"); + return; + } /* replace "ffserver" with "ffmpeg" in the path of current * program. Ignore user provided path */ - av_strlcpy(pathname, my_program_name, sizeof(pathname)); slash = strrchr(pathname, '/'); if (!slash) @@ -445,8 +468,10 @@ static void start_children(FFServerStream *feed) signal(SIGPIPE, SIG_DFL); execvp(pathname, feed->child_argv); + av_free (pathname); _exit(1); } + av_free (pathname); } /* open a listening socket */ @@ -717,8 +742,10 @@ static void http_send_too_busy_reply(int fd) "Content-type: text/html\r\n" "\r\n" "
The server is too busy to serve your request at this time.
\r\n" - "The number of current connections is %u, and this exceeds the limit of %u.
\r\n" + "The server is too busy to serve your request at " + "this time.
\r\n" + "The number of current connections is %u, and this " + "exceeds the limit of %u.
\r\n" "\r\n", nb_connections, config.nb_max_connections); av_assert0(len < sizeof(buffer)); @@ -1462,9 +1489,11 @@ static int http_parse_request(HTTPContext *c) "Content-type: text/html\r\n" "\r\n" "The server is too busy to serve your request at this time.
\r\n" - "The bandwidth being served (including your stream) is %"PRIu64"kbit/sec, " - "and this exceeds the limit of %"PRIu64"kbit/sec.
\r\n" + "The server is too busy to serve your request at " + "this time.
\r\n" + "The bandwidth being served (including your stream) " + "is %"PRIu64"kbit/s, and this exceeds the limit of " + "%"PRIu64"kbit/s.
\r\n" "\r\n", current_bandwidth, config.max_bandwidth); q += strlen(q); @@ -1761,7 +1790,7 @@ static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream) stream_no = stream->nb_streams; avio_printf(pb, "Stream | " - "type | kbits/s | codec | " + "type | kbit/s | codec | "
"Parameters\n");
for (i = 0; i < stream_no; i++) {
@@ -1826,7 +1855,7 @@ static void compute_status(HTTPContext *c)
/* format status */
avio_printf(pb, "Available Streams\n"); avio_printf(pb, "
|
---|