History

avcodec/hevc_mp4toannexb: more validations for nalu_len

For a corrupted stream, the value of nalu_len read from the extradata is not reliable. We need to perform additional checks

Nuo Mi committed 2 years ago

Commit 4f804411 parent f7a504a1 file · +4 −2Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/bsf/hevc_mp4toannexb.c+4−2
@@ -65,9 +65,11 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) · 64 unmodified lines
65 }65 }
66 66
67 for (j = 0; j < cnt; j++) {67 for (j = 0; j < cnt; j++) {
68 int nalu_len = bytestream2_get_be16(&gb);68 const int nalu_len = bytestream2_get_be16(&gb);
69 69
70 if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) {70 if (!nalu_len ||
71 nalu_len > bytestream2_get_bytes_left(&gb) ||
72 4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) {
71 ret = AVERROR_INVALIDDATA;73 ret = AVERROR_INVALIDDATA;
72 goto fail;74 goto fail;
73 }75 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t