aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-10-26 23:58:02 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-31 19:51:56 +0100
commit8f71cd980c5a9244a5c5b2186cbc1fac40876ac7 (patch)
tree1e3edcc4b5953d1ed3663832471c9f885cc92890
parent99243eea7b608472a2bcc8377a1862cc8fe62802 (diff)
downloadffmpeg-8f71cd980c5a9244a5c5b2186cbc1fac40876ac7.tar.gz
avcodec/libvorbisdec: Fix insufficient input checks leading to out of array reads
Fixes: 16144/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVORBIS_fuzzer-5638618940440576 Fixes: out of array read Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 069be4aa5ddce4479b18896d80a852b144e680df) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/libvorbisdec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c
index 89cbbb41b6..3c53b8fdaf 100644
--- a/libavcodec/libvorbisdec.c
+++ b/libavcodec/libvorbisdec.c
@@ -64,22 +64,25 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
}
} else if(*p == 2) {
unsigned int offset = 1;
+ unsigned int sizesum = 1;
p++;
for(i=0; i<2; i++) {
hsizes[i] = 0;
- while((*p == 0xFF) && (offset < avccontext->extradata_size)) {
+ while((*p == 0xFF) && (sizesum < avccontext->extradata_size)) {
hsizes[i] += 0xFF;
offset++;
+ sizesum += 1 + 0xFF;
p++;
}
- if(offset >= avccontext->extradata_size - 1) {
+ hsizes[i] += *p;
+ offset++;
+ sizesum += 1 + *p;
+ if(sizesum > avccontext->extradata_size) {
av_log(avccontext, AV_LOG_ERROR,
"vorbis header sizes damaged\n");
ret = AVERROR_INVALIDDATA;
goto error;
}
- hsizes[i] += *p;
- offset++;
p++;
}
hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset;