]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
Fix stack corruption in httpd
[vlc] / modules / control / http / http.c
index 96f18c8b8e41bcd0ab0ec41a496fed7389ecb960..b587352f0bfe2d0165534d78b3cee43587f654e6 100644 (file)
@@ -124,9 +124,14 @@ static int Open( vlc_object_t *p_this )
                   *psz_crl = NULL;
     int           i_port       = 0;
     char          *psz_src;
-    char          psz_tmp[10];
+    char          *psz_tmp;
 
-    psz_address = config_GetPsz( p_intf, "http-host" );
+    var_Create(p_intf->p_libvlc_global, "http-host", VLC_VAR_STRING );
+    psz_address=var_GetString(p_intf->p_libvlc_global, "http-host");
+    if( !psz_address || !*psz_address )
+    {
+        psz_address = config_GetPsz( p_intf, "http-host" );
+    }
     if( psz_address != NULL )
     {
         char *psz_parser = strchr( psz_address, ':' );
@@ -258,9 +263,14 @@ static int Open( vlc_object_t *p_this )
             i_port= 8080;
     }
 
+    /* maximum port is 65535 , strlen("65535") == 5 */
+    psz_tmp = malloc( ( strlen( psz_address ) + 5 ) * sizeof( char) );
+
     /* Ugly hack to allow to run several HTTP servers on different ports. */
-    sprintf( psz_tmp, ":%d", i_port + 1 );
-    config_PutPsz( p_intf, "http-host", psz_tmp );
+
+    sprintf( psz_tmp, "%s:%d", psz_address, i_port + 1 );
+    var_SetString( p_intf->p_libvlc_global, "http-host", psz_tmp );
+    free( psz_tmp );
 
     msg_Dbg( p_intf, "base %s:%d", psz_address, i_port );
 
@@ -282,7 +292,7 @@ static int Open( vlc_object_t *p_this )
 #if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
     if ( ( psz_src = config_GetPsz( p_intf, "http-src" )) == NULL )
     {
-        char * psz_vlcpath = p_intf->p_libvlc->psz_vlcpath;
+        char * psz_vlcpath = p_intf->p_libvlc_global->psz_vlcpath;
         psz_src = malloc( strlen(psz_vlcpath) + strlen("/share/http" ) + 1 );
         if( !psz_src ) return VLC_ENOMEM;
 #if defined(WIN32)
@@ -426,7 +436,7 @@ static void Run( intf_thread_t *p_intf )
 {
     intf_sys_t     *p_sys = p_intf->p_sys;
 
-    while( !p_intf->b_die )
+    while( !intf_ShouldDie( p_intf ) )
     {
         /* get the playlist */
         if( p_sys->p_playlist == NULL )