aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h261dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-10-30 14:23:30 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-10-30 14:45:39 +0100
commit719dbe86ea0e85b3b89f492c69e10bb0e733bcbb (patch)
treef24ea9ab8bf11dd22016dcfad0ae5de0a4b9cc3a /libavcodec/h261dec.c
parentb0f8b5c8190ae1f8abf56695c8211d6e82022323 (diff)
downloadffmpeg-719dbe86ea0e85b3b89f492c69e10bb0e733bcbb.tar.gz
avcodec/h261dec: make while get_bits loop more robust by checking bits left
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h261dec.c')
-rw-r--r--libavcodec/h261dec.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 5e45fc7b9e..2995d8ca35 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -125,8 +125,11 @@ static int h261_decode_gob_header(H261Context *h)
}
/* GEI */
- while (get_bits1(&s->gb) != 0)
+ while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
+ if (get_bits_left(&s->gb) <= 0)
+ return AVERROR_INVALIDDATA;
+ }
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n");
@@ -505,8 +508,11 @@ static int h261_decode_picture_header(H261Context *h)
skip_bits1(&s->gb); /* Reserved */
/* PEI */
- while (get_bits1(&s->gb) != 0)
+ while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
+ if (get_bits_left(&s->gb) <= 0)
+ return AVERROR_INVALIDDATA;
+ }
/* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first
* frame, the codec crashes if it does not contain all I-blocks