aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-11-09 23:31:30 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-01-21 20:21:32 +0100
commit43c8d3097b8254d08f5413a1934c001327859f47 (patch)
tree7033428e5e9918bf620b87674ebb7c101babf533 /libavcodec
parent1b373b41d940e3058cdfb3d17703e23ed665353c (diff)
downloadffmpeg-43c8d3097b8254d08f5413a1934c001327859f47.tar.gz
avcodec/cri: check for available input in unpack_10bit()
Fixes: Timeout (>20sec -> 56ms) Fixes: 26995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5107217080254464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/cri.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 5234f49965..41be29eabb 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -80,10 +80,13 @@ static void unpack_10bit(GetByteContext *gb, uint16_t *dst, int shift,
int pos = 0;
while (count > 0) {
- uint32_t a0 = bytestream2_get_le32(gb);
- uint32_t a1 = bytestream2_get_le32(gb);
- uint32_t a2 = bytestream2_get_le32(gb);
- uint32_t a3 = bytestream2_get_le32(gb);
+ uint32_t a0, a1,a2,a3;
+ if (bytestream2_get_bytes_left(gb) < 4)
+ break;
+ a0 = bytestream2_get_le32(gb);
+ a1 = bytestream2_get_le32(gb);
+ a2 = bytestream2_get_le32(gb);
+ a3 = bytestream2_get_le32(gb);
dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift;
pos++;
if (pos >= w) {