[vlc-devel] commit: HTTP access_out: fix binding to an IPv6 address ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Sep 8 19:07:12 CEST 2008


vlc | branch: 0.8.6-bugfix | Rémi Denis-Courmont <rdenis at simphalempin.com> | Mon Sep  8 20:08:02 2008 +0300| [387df5ddeba659aed22b52565b2fe18173b208ff] | committer: Rémi Denis-Courmont 

HTTP access_out: fix binding to an IPv6 address

(cherry picked from commit fb6988590b4a3354110d170501838f2dd56fd873)

Conflicts:

	modules/access_output/http.c

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=387df5ddeba659aed22b52565b2fe18173b208ff
---

 modules/access_output/http.c |   57 +++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/modules/access_output/http.c b/modules/access_output/http.c
index ecd1ea3..9ce8371 100644
--- a/modules/access_output/http.c
+++ b/modules/access_output/http.c
@@ -180,45 +180,36 @@ static int Open( vlc_object_t *p_this )
     psz_bind_addr = psz_parser = strdup( p_access->psz_name );
 
     i_bind_port = 0;
-    psz_file_name = "";
 
-    while( *psz_parser && *psz_parser != ':' && *psz_parser != '/' )
-    {
-        psz_parser++;
-    }
-    if( *psz_parser == ':' )
+    psz_parser = strchr( psz_bind_addr, '/' );
+    if( psz_parser )
     {
+        psz_file_name = strdup( psz_parser );
         *psz_parser = '\0';
-        psz_parser++;
-        i_bind_port = atoi( psz_parser );
-
-        while( *psz_parser && *psz_parser != '/' )
-        {
-            psz_parser++;
-        }
     }
-    if( *psz_parser == '/' )
-    {
-        *psz_parser = '\0';
-        psz_parser++;
-        psz_file_name = psz_parser;
-    }
-
-    if( !*psz_file_name )
-    {
+    else
         psz_file_name = strdup( "/" );
-    }
-    else if( *psz_file_name != '/' )
-    {
-        char *p = psz_file_name;
 
-        psz_file_name = malloc( strlen( p ) + 2 );
-        strcpy( psz_file_name, "/" );
-        strcat( psz_file_name, p );
+    if( psz_bind_addr[0] == '[' )
+    {
+        psz_bind_addr++;
+        psz_parser = strstr( psz_bind_addr, "]:" );
+        if( psz_parser )
+        {
+            *psz_parser = '\0';
+            i_bind_port = atoi( psz_parser + 2 );
+        }
+        psz_parser = psz_bind_addr - 1;
     }
     else
     {
-        psz_file_name = strdup( psz_file_name );
+        psz_parser = strrchr( psz_bind_addr, ':' );
+        if( psz_parser )
+        {
+            *psz_parser = '\0';
+            i_bind_port = atoi( psz_parser + 1 );
+        }
+        psz_parser = psz_bind_addr;
     }
 
     /* SSL support */
@@ -244,14 +235,14 @@ static int Open( vlc_object_t *p_this )
                                             psz_crl );
     if( p_sys->p_httpd_host == NULL )
     {
-        msg_Err( p_access, "cannot listen on %s:%d",
+        msg_Err( p_access, "cannot listen on %s port %d",
                  psz_bind_addr, i_bind_port );
         free( psz_file_name );
-        free( psz_bind_addr );
+        free( psz_parser );
         free( p_sys );
         return VLC_EGENERIC;
     }
-    free( psz_bind_addr );
+    free( psz_parser );
 
     if( p_access->psz_access && !strcmp( p_access->psz_access, "mmsh" ) )
     {




More information about the vlc-devel mailing list