]> git.sesse.net Git - ffmpeg/commitdiff
libswcale: Fix possible string overflow in test.
authorAdam Richter <adamrichter4@gmail.com>
Sun, 12 May 2019 12:03:25 +0000 (05:03 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 13 May 2019 11:39:40 +0000 (13:39 +0200)
In libswcale/tests/swcale.c, the function fileTest() calls sscanf in
an argument of "%12s" on character srcStr[] and dstStr[], which are
only 12 bytes.  So, if the input string is 12 characters, a
terminating null byte can be written past the end of these arrays.

This bug was found by cppcheck.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libswscale/tests/swscale.c

index e72c4c3306ad423fabe543b37456b38845220ee8..cb731f6211ce0d36342ecc755119500c2bf00e44 100644 (file)
@@ -312,10 +312,10 @@ static int fileTest(const uint8_t * const ref[4], int refStride[4],
     while (fgets(buf, sizeof(buf), fp)) {
         struct Results r;
         enum AVPixelFormat srcFormat;
-        char srcStr[12];
+        char srcStr[13];
         int srcW = 0, srcH = 0;
         enum AVPixelFormat dstFormat;
-        char dstStr[12];
+        char dstStr[13];
         int dstW = 0, dstH = 0;
         int flags;
         int ret;