]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mov: Fix unaligned read of uint32_t and endian-dependance in mov_read_default
authorZhao Zhili <quinkblack@foxmail.com>
Sat, 4 Jul 2020 16:51:53 +0000 (00:51 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 7 Jul 2020 17:25:19 +0000 (19:25 +0200)
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index df5bebdff186bf066b9ea582fd78a89df8045b6b..da438e4e2c452199a1be3ff09abe712142f7d205 100644 (file)
@@ -6945,13 +6945,12 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
                   a.type == MKTAG('h','o','o','v')) &&
                 a.size >= 8 &&
                 c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT) {
-                uint8_t buf[8];
-                uint32_t *type = (uint32_t *)buf + 1;
-                if (avio_read(pb, buf, 8) != 8)
-                    return AVERROR_INVALIDDATA;
+                uint32_t type;
+                avio_skip(pb, 4);
+                type = avio_rl32(pb);
                 avio_seek(pb, -8, SEEK_CUR);
-                if (*type == MKTAG('m','v','h','d') ||
-                    *type == MKTAG('c','m','o','v')) {
+                if (type == MKTAG('m','v','h','d') ||
+                    type == MKTAG('c','m','o','v')) {
                     av_log(c->fc, AV_LOG_ERROR, "Detected moov in a free or hoov atom.\n");
                     a.type = MKTAG('m','o','o','v');
                 }