Skip to content

Commit

Permalink
Avoid SPS and PPS id array out of bounds in h264 parser
Browse files Browse the repository at this point in the history
Fixes ticket tvheadend#467
  • Loading branch information
andoma committed May 18, 2011
1 parent e9d2c11 commit 8281379
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/parser_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ h264_decode_seq_parameter_set(elementary_stream_t *st, bitstream_t *bs)
level_idc= read_bits(bs, 8);
sps_id= read_golomb_ue(bs);

if(sps_id > 255)
return -1;

i = 0;
while(h264_lev2cpbsize[i][0] != -1) {
Expand Down Expand Up @@ -337,7 +339,12 @@ h264_decode_pic_parameter_set(elementary_stream_t *st, bitstream_t *bs)
p = st->es_priv = calloc(1, sizeof(h264_private_t));

pps_id = read_golomb_ue(bs);
if(pps_id > 255)
return 0;
sps_id = read_golomb_ue(bs);
if(sps_id > 255)
return -1;

p->pps[pps_id].sps = sps_id;
return 0;
}
Expand Down Expand Up @@ -374,6 +381,9 @@ h264_decode_slice_header(elementary_stream_t *st, bitstream_t *bs, int *pkttype,
}

pps_id = read_golomb_ue(bs);
if(pps_id > 255)
return -1;

sps_id = p->pps[pps_id].sps;
if(p->sps[sps_id].max_frame_num_bits == 0)
return -1;
Expand Down

0 comments on commit 8281379

Please sign in to comment.