'sync' group entries consume one byte for the nal_unit_type, which is
accounted for by subtracting 1 from description_length before skipping
the remaining bytes of the entry. description_length is 0 for version 0
atoms (default_length is never read from the bitstream), and version 1
atoms may legally carry default_length == 0 with a per-entry
description_length of 0.
For such entries 0u - 1u wraps to UINT32_MAX and avio_skip() attempts
to skip ~4GB, overreading the atom and failing the demux:
libavformat/mov.c:4138:32: runtime error: unsigned integer
overflow: 0 - 1 cannot be represented in type 'uint32_t'
overread end of atom 'sgpd' by 4294967295 bytes
Skip nothing when description_length is 0: the entry consists of the
already consumed nal_unit_type byte alone.
Reproduced with minimal mp4s carrying an sgpd box (version 0, and
version 1 with zero-length descriptions), parsed by a build
instrumented with -fsanitize=unsigned-integer-overflow.
Signed-off-by: edson bruno <[email protected]>
Signed-off-by: Edson Bruno <[email protected]>
---
libavformat/mov.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0c2f592e7f..85e19454f4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4135,7 +4135,8 @@ static int mov_read_sgpd(MOVContext *c, AVIOContext *pb,
MOVAtom atom)
if (grouping_type == MKTAG('s','y','n','c')) {
const uint8_t nal_unit_type = avio_r8(pb) & 0x3f;
sc->sgpd_sync[i] = nal_unit_type;
- description_length -= 1;
+ if (description_length)
+ description_length -= 1;
}
avio_skip(pb, description_length);
}
--
2.47.3
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]