summaryrefslogtreecommitdiff
path: root/libavcodec/hapdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-02-19 21:16:25 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-02-20 14:16:00 +0100
commit89fe1935b18621af06587c76bcde6adcdc8f2249 (patch)
treebe17167a95a13a55e3cdfa2448b339e39d3ad838 /libavcodec/hapdec.c
parent029e3c1c70b31ede9f17dda4b3a4fc8e35cada70 (diff)
avcodec/hapdec: Change compressed_offset to unsigned 32bit
Fixes: out of array access Fixes: 29345/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5401813482340352 Fixes: 30745/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5762798221131776 Suggested-by: Anton Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/hapdec.c')
-rw-r--r--libavcodec/hapdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index ab364aa790..692bb6e750 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -105,6 +105,8 @@ static int hap_parse_decode_instructions(HapContext *ctx, int size)
size_t running_size = 0;
for (i = 0; i < ctx->chunk_count; i++) {
ctx->chunks[i].compressed_offset = running_size;
+ if (ctx->chunks[i].compressed_size > UINT32_MAX - running_size)
+ return AVERROR_INVALIDDATA;
running_size += ctx->chunks[i].compressed_size;
}
}
@@ -186,7 +188,7 @@ static int hap_parse_frame_header(AVCodecContext *avctx)
HapChunk *chunk = &ctx->chunks[i];
/* Check the compressed buffer is valid */
- if (chunk->compressed_offset + chunk->compressed_size > bytestream2_get_bytes_left(gbc))
+ if (chunk->compressed_offset + (uint64_t)chunk->compressed_size > bytestream2_get_bytes_left(gbc))
return AVERROR_INVALIDDATA;
/* Chunks are unpacked sequentially, ctx->tex_size is the uncompressed