diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-29 18:29:41 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-07 01:00:01 +0100 |
commit | b666debffec1fcbb19ef377635a53b9a58bca8a4 (patch) | |
tree | 649481da1317e8563ba13ee9522526df9fa5d675 | |
parent | c3744b415a97e8385e866613f5da23f6146f28b6 (diff) | |
download | ffmpeg-b666debffec1fcbb19ef377635a53b9a58bca8a4.tar.gz |
huffyuvdec: Check init_vlc() return codes.
Prevents out of array writes
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/huffyuv.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 58da7894e4..993e524799 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -273,6 +273,7 @@ static void generate_joint_tables(HYuvContext *s) int len1 = s->len[p][u]; if (len1 > limit) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y << 8) + u; @@ -307,6 +308,7 @@ static void generate_joint_tables(HYuvContext *s) int len2 = s->len[2][r & 255]; if (len2 > limit1) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r & 255]; if (s->decorrelate) { @@ -331,6 +333,7 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, src, length * 8); @@ -341,8 +344,9 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) return -1; } ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); @@ -354,6 +358,7 @@ static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); @@ -377,8 +382,9 @@ static int read_old_huffman_tables(HYuvContext *s) for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); |