mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-11-06 05:17:42 +00:00
avformat/hevc: reject hvcC NAL arrays that overflow the 16-bit count
numNalus is uint16_t; a crafted hvcC declaring >65535 NAL units of one type wraps it to 0 and then writes nal[-1]. Reject before the count can wrap. Reachable by remuxing a crafted file with -c copy. Fixes: integer overflow Fixes: out of array access
This commit is contained in:
1 parent
9d786e4b5e
commit
acf5d7cdc1
1 file changed
+3
@@ -844,6 +844,9 @@ static int hvcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size,
|
||||
int ret;
|
||||
uint16_t numNalus = array->numNalus;
|
||||
|
||||
if (numNalus >= UINT16_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ret = av_reallocp_array(&array->nal, numNalus + 1, sizeof(*array->nal));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user