1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

ffserver: Fix off by 1 error in path

Code suggested by ubitux

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 617f0c65e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2017-10-22 17:11:20 +02:00
parent bcfbcbec48
commit 561e276899

View File

@ -476,7 +476,7 @@ static int compute_datarate(DataRateData *drd, int64_t count)
static void start_children(FFServerStream *feed)
{
char *pathname;
char *slash;
char *dirname, *prog;
int i;
size_t cmd_length;
@ -495,22 +495,18 @@ static void start_children(FFServerStream *feed)
return;
}
slash = strrchr(my_program_name, '/');
if (!slash) {
pathname = av_mallocz(sizeof("ffmpeg"));
} else {
pathname = av_mallocz(slash - my_program_name + sizeof("ffmpeg"));
if (pathname != NULL) {
memcpy(pathname, my_program_name, slash - my_program_name);
}
/* use "ffmpeg" in the path of current program. Ignore user provided path */
prog = av_strdup(my_program_name);
if (prog) {
dirname = av_dirname(prog);
pathname = *dirname ? av_asprintf("%s/%s", dirname, "ffmpeg")
: av_asprintf("ffmpeg");
av_free(prog);
}
if (!pathname) {
if (!prog || !pathname) {
http_log("Could not allocate memory for children cmd line\n");
return;
}
/* use "ffmpeg" in the path of current program. Ignore user provided path */
strcat(pathname, "ffmpeg");
for (; feed; feed = feed->next) {