[vlc-commits] modules/services_discovery/sap.c: avoid out-of-bounds write

Nickolai Zeldovich git at videolan.org
Thu Jan 17 17:55:15 CET 2013


vlc/vlc-1.1 | branch: master | Nickolai Zeldovich <nickolai at csail.mit.edu> | Wed Jan 16 20:03:20 2013 -0500| [376213a5b183facfde794f17eba688fa137786f5] | committer: Rémi Denis-Courmont

modules/services_discovery/sap.c: avoid out-of-bounds write

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 <remi at remlab.net>
(cherry picked from commit dee928705dd32839317dca0e77089b02dd720763)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=376213a5b183facfde794f17eba688fa137786f5
---

 modules/services_discovery/sap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index a6aee77..9a40bfa 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -372,7 +372,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 )
         {



More information about the vlc-commits mailing list