The current code will ignore the init_get_bits() failure and do an
invalid read from the uninitialized GetBitContext.
Found-By: Jan Ruge <jan.s.ruge@gmail.com>
Bug-Id: 952
Gbp-Pq: Name CVE-2017-
1000460.patch
int nal_index = 0;
int buf_index = 0;
int nals_needed = 0;
+ int ret = 0;
while(1) {
int nalsize = 0;
case NAL_DPA:
case NAL_IDR_SLICE:
case NAL_SLICE:
- init_get_bits(&h->gb, ptr, bit_length);
+ ret = init_get_bits8(&h->gb, ptr, bit_length);
+ if (ret < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid zero-sized VCL NAL unit\n");
+ if (h->avctx->err_recognition & AV_EF_EXPLODE)
+ return ret;
+
+ break;
+ }
if (!get_ue_golomb(&h->gb))
nals_needed = nal_index;
}