From f51f81a04f848d37181325634be9899d8237f390 Mon Sep 17 00:00:00 2001 From: dshaw Date: Fri, 13 Mar 2009 18:59:07 +0000 Subject: [PATCH] * http.c (do_parse_uri): Properly handle IPv6 literal addresses as per RFC-2732. Adapted from patch by Phil Pennock. git-svn-id: svn://cvs.gnupg.org/gnupg/trunk@4949 8a63c251-dffc-0310-8ec6-d64dca2275b1 --- common/ChangeLog | 5 +++++ common/http.c | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/common/ChangeLog b/common/ChangeLog index f5ba7d72..cbe0a5a2 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,8 @@ +2009-03-13 David Shaw + + * 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 * sexputil.c (make_canon_sexp): New. diff --git a/common/http.c b/common/http.c index 96e2a9e0..73a6cb8f 100644 --- a/common/http.c +++ b/common/http.c @@ -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 @@ do_parse_uri (parsed_uri_t uri, int only_local_part) 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; } -- 2.11.4.GIT