For a corrupted stream, the value of nalu_len read from the extradata is not reliable. We need to perform additional checks Fixes: fuzzer timeout Fixes: 65253/clusterfuzz-testcase-minimized-ffmpeg_BSF_VVC_MP4TOANNEXB_fuzzer-4972412487467008
Unified · Split
| @@ -155,10 +155,11 @@ static int vvc_extradata_to_annexb(AVBSFContext *ctx) · 154 unmodified lines | ||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | for (j = 0; j < cnt; j++) { |
| 158 | − int nalu_len = bytestream2_get_be16(&gb); | |
| 158 | + const int nalu_len = bytestream2_get_be16(&gb); | |
| 159 | 159 | |
| 160 | − if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > | |
| 161 | − SIZE_MAX - new_extradata_size) { | |
| 160 | + if (!nalu_len || | |
| 161 | + nalu_len > bytestream2_get_bytes_left(&gb) || | |
| 162 | + 4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { | |
| 162 | 163 | ret = AVERROR_INVALIDDATA; |
| 163 | 164 | goto fail; |
| 164 | 165 | } |