Skip to content

Commit

Permalink
fixed #2165
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Apr 12, 2022
1 parent 37592ad commit 9ea93a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/isomedia/avc_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -3523,6 +3523,11 @@ GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs)
op->layers_info[j].layer_id = gf_bs_read_int(bs, 6);
op->layers_info[j].is_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
op->layers_info[j].is_alternate_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;

if (gf_bs_is_overflow(bs)) {
gf_free(op);
return GF_NON_COMPLIANT_BITSTREAM;
}
}
op->minPicWidth = gf_bs_read_u16(bs);
op->minPicHeight = gf_bs_read_u16(bs);
Expand All @@ -3542,6 +3547,10 @@ GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs)
op->maxBitRate = gf_bs_read_u32(bs);
op->avgBitRate = gf_bs_read_u32(bs);
}
if (gf_bs_is_overflow(bs)) {
gf_free(op);
return GF_NON_COMPLIANT_BITSTREAM;
}
gf_list_add(ptr->operating_points, op);
}
count = gf_bs_read_u8(bs);
Expand All @@ -3561,6 +3570,10 @@ GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs)
if (ptr->scalability_mask & (1 << j))
dep->dimension_identifier[j] = gf_bs_read_u8(bs);
}
if (gf_bs_is_overflow(bs)) {
gf_free(dep);
return GF_NON_COMPLIANT_BITSTREAM;
}
gf_list_add(ptr->dependency_layers, dep);
}

Expand Down
10 changes: 8 additions & 2 deletions src/utils/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,12 @@ static u8 BS_ReadByte(GF_BitStream *bs)
bs_flush_write_cache(bs);

is_eos = gf_feof(bs->stream);
//cache not fully read, reset EOS
if (bs->cache_read && (bs->cache_read_pos<bs->cache_read_size))
is_eos = GF_FALSE;

/*we are in FILE mode, test for end of file*/
if (!is_eos || bs->cache_read) {
if (!is_eos) {
u8 res;
Bool loc_eos=GF_FALSE;
assert(bs->position<=bs->size);
Expand Down Expand Up @@ -408,7 +411,10 @@ static u8 BS_ReadByte(GF_BitStream *bs)
bs->EndOfStream(bs->par);
if (!bs->overflow_state) bs->overflow_state = 1;
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[BS] Attempt to overread bitstream\n"));
if (!bs->overflow_state) {
bs->overflow_state = 1;
GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[BS] Attempt to overread bitstream\n"));
}
}
assert(bs->position <= 1+bs->size);
return 0;
Expand Down

0 comments on commit 9ea93a2

Please sign in to comment.