]> git.sesse.net Git - ffmpeg/commitdiff
diracdec: fix unchecked byte length
authorRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 13 Jul 2016 22:53:05 +0000 (23:53 +0100)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 13 Jul 2016 22:53:05 +0000 (23:53 +0100)
Also drops the start variable since it's redundant.
Found by Coverity, fixes CID1363964

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/diracdec.c

index dc42a42d86056fd2614fbd155f8066ab9db5b346..6cb098b08c8531908d9d7e3a03d458ded613912a 100644 (file)
@@ -835,11 +835,10 @@ static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
     for (i = 0; i < 3; i++) {
         int coef_num, coef_par, off = 0;
         int64_t length = s->highquality.size_scaler*get_bits(gb, 8);
-        int64_t start = get_bits_count(gb);
-        int64_t bits_end = start + 8*length;
+        int64_t bits_end = get_bits_count(gb) + 8*length;
         const uint8_t *addr = align_get_bits(gb);
 
-        if (bits_end >= INT_MAX) {
+        if (length*8 > get_bits_left(gb)) {
             av_log(s->avctx, AV_LOG_ERROR, "end too far away\n");
             return AVERROR_INVALIDDATA;
         }