Skip to content

Commit

Permalink
fix default value for fd in new bitstreams
Browse files Browse the repository at this point in the history
ossfuzz issue 67118
  • Loading branch information
aureliendavid committed Mar 6, 2024
1 parent b1d00c9 commit 322790f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/isomedia/media.c
Expand Up @@ -639,13 +639,9 @@ GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp,

//check if we can get the sample (make sure we have enougth data...)
new_size = gf_bs_get_size(mdia->information->dataHandler->bs);
if (offset > new_size) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("%s:%d datahandler %p data %p dataLength %d offset %ld data_size %d new_size %ld\n", __FILE__, __LINE__, mdia->information->dataHandler, (*samp)->data, (*samp)->dataLength, offset, data_size, new_size));
}
if (offset + data_size > new_size) {
//always refresh the size to avoid wrong info on http/ftp
new_size = gf_bs_get_refreshed_size(mdia->information->dataHandler->bs);
GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("%s:%d datahandler %p data %p dataLength %d offset %ld data_size %d new_size %ld\n", __FILE__, __LINE__, mdia->information->dataHandler, (*samp)->data, (*samp)->dataLength, offset, data_size, new_size));
if (offset + data_size > new_size) {
mdia->BytesMissing = offset + data_size - new_size;
return GF_ISOM_INCOMPLETE_FILE;
Expand Down
4 changes: 3 additions & 1 deletion src/utils/bitstream.c
Expand Up @@ -135,6 +135,9 @@ GF_BitStream *gf_bs_new(const u8 *buffer, u64 BufferSize, u32 mode)
GF_BitStream *tmp = (GF_BitStream *)gf_malloc(sizeof(GF_BitStream));
if (!tmp) return NULL;
memset(tmp, 0, sizeof(GF_BitStream));
#ifdef GPAC_HAS_FD
tmp->fd = -1;
#endif

tmp->original = (char*)buffer;
tmp->size = BufferSize;
Expand Down Expand Up @@ -1603,7 +1606,6 @@ GF_EXPORT
u64 gf_bs_get_refreshed_size(GF_BitStream *bs)
{
s64 offset;

switch (bs->bsmode) {
case GF_BITSTREAM_READ:
case GF_BITSTREAM_WRITE:
Expand Down

0 comments on commit 322790f

Please sign in to comment.