[FFmpeg-cvslog] fftools/ffprobe: Fix hypothetical stack buffer overflow

Andreas Rheinhardt git at videolan.org
Thu Apr 3 07:28:47 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Mar 31 10:01:07 2025 +0200| [9d543273fe6f0a8d052f48b60427d26e3a4e07fb] | committer: Andreas Rheinhardt

fftools/ffprobe: Fix hypothetical stack buffer overflow

It can't really happen, because no currently used pixel format
has a name exceeding the size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 fftools/ffprobe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index ccc046c560..abbd1dcf36 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2666,10 +2666,10 @@ static void print_pixel_format(WriterContext *w, enum AVPixelFormat pix_fmt)
         char buf[128];
         size_t i = 0;
 
-        while (s[i] && s[i] == s2[i])
+        while (s[i] && s[i] == s2[i] && i < sizeof(buf) - 1) {
+            buf[i] = s[i];
             i++;
-
-        memcpy(buf, s, FFMIN(sizeof(buf) - 1, i));
+        }
         buf[i] = '\0';
 
         print_str    ("pix_fmt", buf);



More information about the ffmpeg-cvslog mailing list