[FFmpeg-cvslog] ffserver: Fix off by 1 error in path
Michael Niedermayer
git at videolan.org
Thu Oct 26 19:39:13 EEST 2017
ffmpeg | branch: release/3.3 | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 22 17:11:20 2017 +0200| [0ccb27e0942701622d1065db58d6adf0d0643d32] | committer: Michael Niedermayer
ffserver: Fix off by 1 error in path
Code suggested by ubitux
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 617f0c65e1bac8983a5b6521818c1b9b57f0804b)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ccb27e0942701622d1065db58d6adf0d0643d32
---
ffserver.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/ffserver.c b/ffserver.c
index 8b819b6934..193f63bd7a 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -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);
- }
- }
- if (!pathname) {
+ /* 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 (!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) {
More information about the ffmpeg-cvslog
mailing list