mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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>
This commit is contained in:
parent
1850c3feaa
commit
069be4aa5d
@ -64,22 +64,25 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
|
|||||||
}
|
}
|
||||||
} else if(*p == 2) {
|
} else if(*p == 2) {
|
||||||
unsigned int offset = 1;
|
unsigned int offset = 1;
|
||||||
|
unsigned int sizesum = 1;
|
||||||
p++;
|
p++;
|
||||||
for(i=0; i<2; i++) {
|
for(i=0; i<2; i++) {
|
||||||
hsizes[i] = 0;
|
hsizes[i] = 0;
|
||||||
while((*p == 0xFF) && (offset < avccontext->extradata_size)) {
|
while((*p == 0xFF) && (sizesum < avccontext->extradata_size)) {
|
||||||
hsizes[i] += 0xFF;
|
hsizes[i] += 0xFF;
|
||||||
offset++;
|
offset++;
|
||||||
|
sizesum += 1 + 0xFF;
|
||||||
p++;
|
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,
|
av_log(avccontext, AV_LOG_ERROR,
|
||||||
"vorbis header sizes damaged\n");
|
"vorbis header sizes damaged\n");
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
hsizes[i] += *p;
|
|
||||||
offset++;
|
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset;
|
hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user