[FFmpeg-cvslog] ffprobe: avoid unsafe usage of the snprintf() return code

Michael Niedermayer git at videolan.org
Sun Sep 9 14:48:46 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Sep  9 14:26:42 2012 +0200| [7992814920d3a07a0bacfe45abd2183e81ef95f9] | committer: Michael Niedermayer

ffprobe: avoid unsafe usage of the snprintf() return code

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

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

 ffprobe.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 754475e..6649b86 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -116,7 +116,6 @@ static char *value_string(char *buf, int buf_size, struct unit_value uv)
         snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
     } else {
         const char *prefix_string = "";
-        int l;
 
         if (use_value_prefix && vald > 1) {
             long long int index;
@@ -135,10 +134,10 @@ static char *value_string(char *buf, int buf_size, struct unit_value uv)
         }
 
         if (show_float || (use_value_prefix && vald != (long long int)vald))
-            l = snprintf(buf, buf_size, "%f", vald);
+            snprintf(buf, buf_size, "%f", vald);
         else
-            l = snprintf(buf, buf_size, "%lld", (long long int)vald);
-        snprintf(buf+l, buf_size-l, "%s%s%s", *prefix_string || show_value_unit ? " " : "",
+            snprintf(buf, buf_size, "%lld", (long long int)vald);
+        av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || show_value_unit ? " " : "",
                  prefix_string, show_value_unit ? uv.unit : "");
     }
 



More information about the ffmpeg-cvslog mailing list