History

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

Michael Niedermayer committed 7 years ago

Commit 069be4a1 parent 1850c3f1 file · +7 −4Browse files

Unified · Split

libavcodec/libvorbisdec.c+7−4
@@ -64,22 +64,25 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) { · 63 unmodified lines
6464 }
6565 } else if(*p == 2) {
6666 unsigned int offset = 1;
67+ unsigned int sizesum = 1;
6768 p++;
6869 for(i=0; i<2; i++) {
6970 hsizes[i] = 0;
70− while((*p == 0xFF) && (offset < avccontext->extradata_size)) {
71+ while((*p == 0xFF) && (sizesum < avccontext->extradata_size)) {
7172 hsizes[i] += 0xFF;
7273 offset++;
74+ sizesum += 1 + 0xFF;
7375 p++;
7476 }
75− if(offset >= avccontext->extradata_size - 1) {
77+ hsizes[i] += *p;
78+ offset++;
79+ sizesum += 1 + *p;
80+ if(sizesum > avccontext->extradata_size) {
7681 av_log(avccontext, AV_LOG_ERROR,
7782 "vorbis header sizes damaged\n");
7883 ret = AVERROR_INVALIDDATA;
7984 goto error;
8085 }
81− hsizes[i] += *p;
82− offset++;
8386 p++;
8487 }
8588 hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t