Skip to content

Commit

Permalink
modules/services_discovery/sap.c: avoid out-of-bounds write
Browse files Browse the repository at this point in the history
After OpenDemux reads data using stream_Read(), it writes a '\0' to
the buffer after the newly-read data, but if the stream returned exactly
i_read_max bytes, this '\0' will end up just past the end of the allocated
psz_sdp array (see the call to realloc at the beginning of the loop).
Adjust the realloc call to allocate this one extra byte.

Signed-off-by: Rémi Denis-Courmont <[email protected]>
  • Loading branch information
zeldovich authored and Rémi Denis-Courmont committed Jan 17, 2013
1 parent 301c200 commit dee9287
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/services_discovery/sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static int OpenDemux( vlc_object_t *p_this )
for( i_len = 0, psz_sdp = NULL; i_len < 65536; )
{
const int i_read_max = 1024;
char *psz_sdp_new = realloc( psz_sdp, i_len + i_read_max );
char *psz_sdp_new = realloc( psz_sdp, i_len + i_read_max + 1 );
size_t i_read;
if( psz_sdp_new == NULL )
{
Expand Down

0 comments on commit dee9287

Please sign in to comment.