Browse Source

avcodec/magicyuv: Improve overread check when parsing Huffman tables

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
tags/n4.4
Andreas Rheinhardt 5 years ago
parent
commit
85737a4d76
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      libavcodec/magicyuv.c

+ 6
- 1
libavcodec/magicyuv.c View File

@@ -394,8 +394,13 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max)
while (get_bits_left(gbit) >= 8) { while (get_bits_left(gbit) >= 8) {
int b = get_bits(gbit, 1); int b = get_bits(gbit, 1);
int x = get_bits(gbit, 7); int x = get_bits(gbit, 7);
int l = get_bitsz(gbit, b * 8) + 1;
int l = 1;


if (b) {
if (get_bits_left(gbit) < 8)
break;
l += get_bits(gbit, 8);
}
k = j + l; k = j + l;
if (k > max || x == 0 || x > 32) { if (k > max || x == 0 || x > 32) {
av_log(avctx, AV_LOG_ERROR, "Invalid Huffman codes\n"); av_log(avctx, AV_LOG_ERROR, "Invalid Huffman codes\n");


Loading…
Cancel
Save