This fixes a possibly exploitable buffer overflow and it will likely also be needed for future overreading fixes.
Originally committed as revision 25546 to svn://svn.ffmpeg.org/ffmpeg/trunk
/* AC coefs */
i = 0;
{OPEN_READER(re, &s->gb)
- for(;;) {
+ do {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j];
}
- }
+ }while(i<63);
CLOSE_READER(re, &s->gb)}
return 0;
}else{
if(run == 0xF){// ZRL - skip 15 coefficients
i += 15;
+ if (i >= se) {
+ av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
+ return -1;
+ }
}else{
val = (1 << run);
if(run){