Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix some exploitable overflows (#994, #997)
  • Loading branch information
aureliendavid committed Mar 6, 2018
1 parent 02daef9 commit 90dc7f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/gpac/tools.h
Expand Up @@ -1067,6 +1067,7 @@ void gf_fm_request_call(u32 type, u32 param, int *value);

/* \endcond */

#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))

#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions src/isomedia/avc_ext.c
Expand Up @@ -2413,6 +2413,8 @@ GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs)
op->output_layer_set_idx = gf_bs_read_u16(bs);
op->max_temporal_id = gf_bs_read_u8(bs);
op->layer_count = gf_bs_read_u8(bs);
if (op->layer_count > ARRAY_LENGTH(op->layers_info))
return GF_NON_COMPLIANT_BITSTREAM;
for (j = 0; j < op->layer_count; j++) {
op->layers_info[j].ptl_idx = gf_bs_read_u8(bs);
op->layers_info[j].layer_id = gf_bs_read_int(bs, 6);
Expand Down
4 changes: 4 additions & 0 deletions src/media_tools/av_parsers.c
Expand Up @@ -2385,6 +2385,10 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32
sps->offset_for_non_ref_pic = bs_get_se(bs);
sps->offset_for_top_to_bottom_field = bs_get_se(bs);
sps->poc_cycle_length = bs_get_ue(bs);
if (sps->poc_cycle_length > ARRAY_LENGTH(sps->offset_for_ref_frame)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[avc-h264] offset_for_ref_frame overflow from poc_cycle_length\n"));
goto exit;
}
for(i=0; i<sps->poc_cycle_length; i++) sps->offset_for_ref_frame[i] = bs_get_se(bs);
}
if (sps->poc_type > 2) {
Expand Down

0 comments on commit 90dc7f8

Please sign in to comment.