[svn] GnuPG - r4948 - branches/STABLE-BRANCH-1-4/util

svn author dshaw cvs at cvs.gnupg.org
Fri Mar 13 18:51:05 CET 2009


Author: dshaw
Date: 2009-03-13 18:51:05 +0100 (Fri, 13 Mar 2009)
New Revision: 4948

Modified:
   branches/STABLE-BRANCH-1-4/util/ChangeLog
   branches/STABLE-BRANCH-1-4/util/http.c
Log:
* http.c (do_parse_uri): Properly handle IPv6 literal addresses as per
RFC-2732.  Adapted from patch by Phil Pennock.


Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/util/ChangeLog	2009-03-13 17:27:35 UTC (rev 4947)
+++ branches/STABLE-BRANCH-1-4/util/ChangeLog	2009-03-13 17:51:05 UTC (rev 4948)
@@ -1,5 +1,8 @@
 2009-03-13  David Shaw  <dshaw at jabberwocky.com>
 
+	* http.c (do_parse_uri): Properly handle IPv6 literal addresses as
+	per RFC-2732.  Adapted from patch by Phil Pennock.
+
 	* Makefile.am, http.c (start_server): Minor tweaks to get
 	http-test compiling again.
 

Modified: branches/STABLE-BRANCH-1-4/util/http.c
===================================================================
--- branches/STABLE-BRANCH-1-4/util/http.c	2009-03-13 17:27:35 UTC (rev 4947)
+++ branches/STABLE-BRANCH-1-4/util/http.c	2009-03-13 17:51:05 UTC (rev 4948)
@@ -343,16 +343,27 @@
 	      }
 
 	    strlwr( p );
-	    uri->host = p;
-	    if( (p3=strchr( p, ':' )) ) {
-		*p3++ = 0;
+
+	    /* Handle a host of [IP] so that [IP:V6]:port works */
+	    if( *p == '[' && (p3=strchr( p, ']' )) )
+	      {
+		*p3++ = '\0';
+		/* worst case, uri->host should have length 0, points to \0 */
+		uri->host = p + 1;
+		p = p3;
+	      }
+	    else
+	      uri->host = p;
+
+	    if( (p3=strchr( p, ':' )) )
+	      {
+		*p3++ = '\0';
 		uri->port = atoi( p3 );
-	    }
+	      }
 
-	    uri->host = p;
 	    if( (n = remove_escapes( uri->host )) < 0 )
 		return G10ERR_BAD_URI;
-	    if( n != strlen( p ) )
+	    if( n != strlen( uri->host ) )
 		return G10ERR_BAD_URI; /* hostname with a Nul in it */
 	    p = p2 ? p2 : NULL;
 	}




More information about the Gnupg-commits mailing list