Fix heap overflow access in vorbis decoder with specially crafted ogg file, fixes #591 (Thanks khang06)

This commit is contained in:
UnknownShadow200 2019-06-13 11:52:21 +10:00
parent ad314a5c55
commit 9ac97942c2

View File

@ -313,17 +313,16 @@ static ReturnCode Codebook_DecodeSetup(struct VorbisState* ctx, struct Codebook*
}
} else {
len = Vorbis_ReadBits(ctx, 5) + 1;
for (entry = 0; entry < c->Entries; entry += runLen) {
for (entry = 0; entry < c->Entries;) {
runBits = iLog(c->Entries - entry);
runLen = Vorbis_ReadBits(ctx, runBits);
for (i = entry; i < entry + runLen; i++) {
codewordLens[i] = len;
}
/* handle corrupted ogg files */
if (entry + runLen > c->Entries) return VORBIS_ERR_CODEBOOK_ENTRY;
for (i = 0; i < runLen; i++) { codewordLens[entry++] = len; }
c->NumCodewords[len++] = runLen;
if (entry > c->Entries) return VORBIS_ERR_CODEBOOK_ENTRY;
}
entry = c->Entries;
}
c->TotalCodewords = entry;