Skip to content

Commit

Permalink
framing: check for overflow on growing buffer
Browse files Browse the repository at this point in the history
newsize is a long, but storage is an int. This means the allocation
could succeed but storage would overflow.

Closes #2300
  • Loading branch information
ubitux committed Aug 9, 2020
1 parent 0bbcba4 commit 684c737
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/framing.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,14 @@ char *ogg_sync_buffer(ogg_sync_state *oy, long size){

if(size>oy->storage-oy->fill){
/* We need to extend the internal buffer */
long newsize=size+oy->fill+4096; /* an extra page to be nice */
long newsize;
void *ret;

if(size>INT_MAX-4096-oy->fill){
ogg_sync_clear(oy);
return NULL;
}
newsize=size+oy->fill+4096; /* an extra page to be nice */
if(oy->data)
ret=_ogg_realloc(oy->data,newsize);
else
Expand Down

0 comments on commit 684c737

Please sign in to comment.