diff mbox series

[FFmpeg-devel,v2,1/1] return value check for init_get_bits in wmadec.c

Message ID PAXP193MB1262A06EE8DBC975F94C816CB6F99@PAXP193MB1262.EURP193.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,v2,1/1] return value check for init_get_bits in wmadec.c | expand

Checks

Context Check Description
andriy/x86_make_warn warning New warnings during build
andriy/x86_make success Make finished
andriy/x86_make_fate fail Make fate failed
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Maryam Ebrahimzadeh Aug. 12, 2021, 5:50 a.m. UTC
sorry for my mistake.
previous version faild to make.
---
 libavcodec/sipr.c        |  5 +++--
 libavcodec/truemotion2.c | 12 +++++++++---
 libavcodec/utvideodec.c  |  8 ++++++--
 libavcodec/vaapi_mpeg2.c |  5 ++++-
 libavcodec/vble.c        |  5 +++--
 libavcodec/vc1dec.c      |  8 ++++++--
 libavcodec/vorbisdec.c   |  8 ++++++--
 libavcodec/vp6.c         |  4 +++-
 libavcodec/wmadec.c      |  1 -
 9 files changed, 40 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
index a792b22c9f..362b475bea 100644
--- a/libavcodec/sipr.c
+++ b/libavcodec/sipr.c
@@ -547,8 +547,9 @@  static int sipr_decode_frame(AVCodecContext *avctx, void *data,
         return ret;
     samples = (float *)frame->data[0];
 
-    init_get_bits(&gb, buf, mode_par->bits_per_frame);
-
+    ret = init_get_bits8(&gb, buf, (mode_par->bits_per_frame)/8);
+    if (ret < 0)
+        return ret;
     for (i = 0; i < mode_par->frames_per_packet; i++) {
         decode_parameters(&parm, &gb, mode_par);
 
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index f29db593f9..f6fedc22d4 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -317,7 +317,9 @@  static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
             pos = bytestream2_tell(&gb);
             if (skip <= pos)
                 return AVERROR_INVALIDDATA;
-            init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
+            ret = init_get_bits8(&ctx->gb, buf + pos, (skip - pos));
+            if (ret < 0)
+                return ret;
             if ((ret = tm2_read_deltas(ctx, stream_id)) < 0)
                 return ret;
             bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
@@ -334,7 +336,9 @@  static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
     pos = bytestream2_tell(&gb);
     if (skip <= pos)
         return AVERROR_INVALIDDATA;
-    init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
+    ret = init_get_bits8(&ctx->gb, buf + pos, (skip - pos));
+    if (ret < 0)
+        return ret;
     if ((ret = tm2_build_huff_table(ctx, &codes)) < 0)
         return ret;
     bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
@@ -359,7 +363,9 @@  static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
             ret = AVERROR_INVALIDDATA;
             goto end;
         }
-        init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
+        init_get_bits8(&ctx->gb, buf + pos, (skip - pos));
+        if (ret < 0)
+            return ret;
         for (i = 0; i < toks; i++) {
             if (get_bits_left(&ctx->gb) <= 0) {
                 av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index b39d8a7948..144992ff0d 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -153,7 +153,9 @@  static int decode_plane10(UtvideoContext *c, int plane_no,
         c->bdsp.bswap_buf((uint32_t *) c->slice_bits,
                           (uint32_t *)(src + slice_data_start + c->slices * 4),
                           (slice_data_end - slice_data_start + 3) >> 2);
-        init_get_bits(&gb, c->slice_bits, slice_size * 8);
+        ret = init_get_bits8(&gb, c->slice_bits, slice_size);
+        if (ret < 0)
+            return ret;
 
         prev = 0x200;
         for (j = sstart; j < send; j++) {
@@ -314,7 +316,9 @@  static int decode_plane(UtvideoContext *c, int plane_no,
         c->bdsp.bswap_buf((uint32_t *) c->slice_bits,
                           (uint32_t *)(src + slice_data_start + c->slices * 4),
                           (slice_data_end - slice_data_start + 3) >> 2);
-        init_get_bits(&gb, c->slice_bits, slice_size * 8);
+        ret = init_get_bits8(&gb, c->slice_bits, slice_size);
+        if (ret < 0)
+            return ret;
 
         prev = 0x80;
         for (j = sstart; j < send; j++) {
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index 26e0cd827c..8e3903212a 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -136,9 +136,12 @@  static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
     GetBitContext gb;
     uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset;
     int err;
+    int ret;
 
     /* Determine macroblock_offset */
-    init_get_bits(&gb, buffer, 8 * size);
+    ret = init_get_bits8(&gb, buffer, size);
+    if (ret < 0 )
+        return ret;
     if (get_bits_long(&gb, 32) >> 8 != 1) /* start code */
         return AVERROR_INVALIDDATA;
     quantiser_scale_code = get_bits(&gb, 5);
diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index f1400959e0..d3e1804c7b 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -146,8 +146,9 @@  static int vble_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     if (version != 1)
         av_log(avctx, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", version);
 
-    init_get_bits(&gb, src + 4, (avpkt->size - 4) * 8);
-
+    ret = init_get_bits8(&gb, src + 4, (avpkt->size - 4) );
+    if (ret < 0)
+        return ret;
     /* Unpack */
     if (vble_unpack(ctx, &gb) < 0) {
         av_log(avctx, AV_LOG_ERROR, "Invalid Code\n");
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 1fb1950ade..07d60294f2 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -444,7 +444,9 @@  static av_cold int vc1_decode_init(AVCodecContext *avctx)
         // the last byte of the extradata is a version number, 1 for the
         // samples we can decode
 
-        init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);
+        ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
+        if (ret < 0)
+            return ret;
 
         if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0)
           return ret;
@@ -771,7 +773,9 @@  static int vc1_decode_frame(AVCodecContext *avctx, void *data,
         }
         init_get_bits(&s->gb, buf2, buf_size2*8);
     } else
-        init_get_bits(&s->gb, buf, buf_size*8);
+        ret = init_get_bits8(&s->gb, buf, buf_size);
+        if (ret < 0)
+            return ret;
 
     if (v->res_sprite) {
         v->new_sprite  = !get_bits1(&s->gb);
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index dac2b6841c..80358f6359 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1052,7 +1052,9 @@  static av_cold int vorbis_decode_init(AVCodecContext *avctx)
         return ret;
     }
 
-    init_get_bits(gb, header_start[0], header_len[0]*8);
+    ret = init_get_bits8(gb, header_start[0], header_len[0]);
+    if (ret < 0)
+        return ret;
     hdr_type = get_bits(gb, 8);
     if (hdr_type != 1) {
         av_log(avctx, AV_LOG_ERROR, "First header is not the id header.\n");
@@ -1064,7 +1066,9 @@  static av_cold int vorbis_decode_init(AVCodecContext *avctx)
         return ret;
     }
 
-    init_get_bits(gb, header_start[2], header_len[2]*8);
+    ret = init_get_bits8(gb, header_start[2], header_len[2]);
+    if (ret < 0)
+        return ret;
     hdr_type = get_bits(gb, 8);
     if (hdr_type != 5) {
         av_log(avctx, AV_LOG_ERROR, "Third header is not the setup header.\n");
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 73822a00f9..149daa59f3 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -167,7 +167,9 @@  static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size)
         }
         if (s->use_huffman) {
             s->parse_coeff = vp6_parse_coeff_huffman;
-            init_get_bits(&s->gb, buf, buf_size<<3);
+            ret = init_get_bits8(&s->gb, buf, (buf_size<<3)/8);
+            if (ret < 0)
+                return ret;
         } else {
             ret = ff_vp56_init_range_decoder(&s->cc, buf, buf_size);
             if (ret < 0)
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 6ac6221d11..0bbc685c89 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -822,7 +822,6 @@  static int wma_decode_superframe(AVCodecContext *avctx, void *data,
     uint8_t *q;
     float **samples;
     int samples_offset;
-    int ret;
 
     ff_tlog(avctx, "***decode_superframe:\n");