[svn] GnuPG - r4949 - trunk/common

svn author dshaw cvs at cvs.gnupg.org
Fri Mar 13 19:59:07 CET 2009


Author: dshaw
Date: 2009-03-13 19:59:07 +0100 (Fri, 13 Mar 2009)
New Revision: 4949

Modified:
   trunk/common/ChangeLog
   trunk/common/http.c
Log:
* http.c (do_parse_uri): Properly handle IPv6 literal addresses as per
RFC-2732.  Adapted from patch by Phil Pennock.


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2009-03-13 17:51:05 UTC (rev 4948)
+++ trunk/common/ChangeLog	2009-03-13 18:59:07 UTC (rev 4949)
@@ -1,3 +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.
+
 2009-03-06  Werner Koch  <wk at g10code.com>
 
 	* sexputil.c (make_canon_sexp): New.

Modified: trunk/common/http.c
===================================================================
--- trunk/common/http.c	2009-03-13 17:51:05 UTC (rev 4948)
+++ trunk/common/http.c	2009-03-13 18:59:07 UTC (rev 4949)
@@ -1,6 +1,6 @@
 /* http.c  -  HTTP protocol handler
- * Copyright (C) 1999, 2001, 2002, 2003, 2004,
- *               2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006,
+ *               2009 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -623,17 +623,27 @@
 
           for (pp=p; *pp; pp++)
             *pp = tolower (*(unsigned char*)pp);
-	  uri->host = p;
+
+	  /* Handle an IPv6 literal */
+	  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;
+	      *p3++ = '\0';
 	      uri->port = atoi (p3);
 	    }
 
-	  uri->host = p;
 	  if ((n = remove_escapes (uri->host)) < 0)
 	    return gpg_error (GPG_ERR_BAD_URI);
-	  if (n != strlen (p))
+	  if (n != strlen (uri->host))
 	    return gpg_error (GPG_ERR_BAD_URI);	/* Hostname incudes a Nul. */
 	  p = p2 ? p2 : NULL;
 	}




More information about the Gnupg-commits mailing list