avformat/nuv: return early if header id fails to read
authorKacper Michajłow <kasper93@gmail.com>
Tue, 25 Jun 2024 21:50:30 +0000 (23:50 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 21 Jun 2026 15:59:33 +0000 (17:59 +0200)
Fixes use of uninitialized value in memcmp below, reported by MSAN.

Found by OSS-Fuzz.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 02b3fc582693477555ce151515972bfee04367a9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/nuv.c

index df90df49385278e845b378e8b6084c1ad012961d..7cf5172da80dc998a4877aca1a16a854fff3eb6c 100644 (file)
@@ -24,6 +24,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 #include "riff.h"
 
@@ -162,7 +163,9 @@ static int nuv_header(AVFormatContext *s)
     int is_mythtv, width, height, v_packs, a_packs, ret;
     AVStream *vst = NULL, *ast = NULL;
 
-    avio_read(pb, id_string, 12);
+    if ((ret = ffio_read_size(pb, id_string, 12)) < 0)
+        return ret;
+
     is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
     avio_skip(pb, 5);       // version string
     avio_skip(pb, 3);       // padding