diff options
author | David Shaw <dshaw@jabberwocky.com> | 2009-03-13 19:59:07 +0100 |
---|---|---|
committer | David Shaw <dshaw@jabberwocky.com> | 2009-03-13 19:59:07 +0100 |
commit | 104712d412ccbf0773465e564ac0b9db921246b0 (patch) | |
tree | 2f3c30dafcb39851db2e9b9d95e324542cacdd82 /common | |
parent | Add new attribute KEY-ATTR. (diff) | |
download | gnupg2-104712d412ccbf0773465e564ac0b9db921246b0.tar.xz gnupg2-104712d412ccbf0773465e564ac0b9db921246b0.zip |
* http.c (do_parse_uri): Properly handle IPv6 literal addresses as per
RFC-2732. Adapted from patch by Phil Pennock.
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 5 | ||||
-rw-r--r-- | common/http.c | 22 |
2 files changed, 21 insertions, 6 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index f5ba7d725..cbe0a5a28 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,8 @@ +2009-03-13 David Shaw <dshaw@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@g10code.com> * sexputil.c (make_canon_sexp): New. diff --git a/common/http.c b/common/http.c index 96e2a9e0b..73a6cb8fb 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; } |