[FFmpeg-cvslog] ffmpeg_filter: fix unsafe snprintf() usage

Michael Niedermayer git at videolan.org
Sun Sep 9 14:23:15 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Sep  9 14:11:03 2012 +0200| [d7cb5a8daf73825d4ffa623be4c2b798c81f41a5] | committer: Michael Niedermayer

ffmpeg_filter: fix unsafe snprintf() usage

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7cb5a8daf73825d4ffa623be4c2b798c81f41a5
---

 ffmpeg_filter.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index b7f20cc..1887ffe 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -424,18 +424,17 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
     if (sample_fmts || sample_rates || channel_layouts) {
         AVFilterContext *format;
         char args[256];
-        int len = 0;
+        args[0] = 0;
 
         if (sample_fmts)
-            len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:",
+            av_strlcatf(args, sizeof(args), "sample_fmts=%s:",
                             sample_fmts);
         if (sample_rates)
-            len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:",
+            av_strlcatf(args, sizeof(args), "sample_rates=%s:",
                             sample_rates);
         if (channel_layouts)
-            len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:",
+            av_strlcatf(args, sizeof(args), "channel_layouts=%s:",
                             channel_layouts);
-        args[len - 1] = 0;
 
         av_freep(&sample_fmts);
         av_freep(&sample_rates);



More information about the ffmpeg-cvslog mailing list