aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-11-27 18:30:05 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-12-05 23:48:52 +0100
commitc6b81e252e7a808d506adf0ee8520a7970426ff7 (patch)
tree6fb74de337703662a5c5a8787cf198ea0d0ee2ec
parentd3de02d9d44256dd2b5c5239bdb2f3830ba8da44 (diff)
downloadffmpeg-c6b81e252e7a808d506adf0ee8520a7970426ff7.tar.gz
avcodec/hevc: Check entry_point_offsets
Fixes out of array read Fixes: 007c4a36608ebdf27ee260ad60a81184/asan_heap-oob_32076b4_2243_116b1cb29d91cc4974d6680e3d10bd91.bit Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit ef9f7bbfa47317f9d46bf46982a394d2be78503c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/hevc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 2f440a6daf..5bba4bb8c1 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2391,7 +2391,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
HEVCLocalContext *lc = s->HEVClc;
int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
- int offset;
+ int64_t offset;
int startheader, cmpt = 0;
int i, j, res = 0;
@@ -2432,6 +2432,11 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
}
if (s->sh.num_entry_point_offsets != 0) {
offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;
+ if (length < offset) {
+ av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");
+ res = AVERROR_INVALIDDATA;
+ goto error;
+ }
s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
@@ -2458,6 +2463,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
res += ret[i];
+error:
av_free(ret);
av_free(arg);
return res;