diff options
author | David Shaw <[email protected]> | 2009-03-13 17:51:05 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2009-03-13 17:51:05 +0000 |
commit | f801e0f9a856bef039b902829fd0c595c7eac56e (patch) | |
tree | 1ab53e2e41c7ced975ed97e72421c6cd90d58a8f | |
parent | * Makefile.am, http.c (start_server): Minor tweaks to get http-test (diff) | |
download | gnupg-f801e0f9a856bef039b902829fd0c595c7eac56e.tar.gz gnupg-f801e0f9a856bef039b902829fd0c595c7eac56e.zip |
* http.c (do_parse_uri): Properly handle IPv6 literal addresses as per
RFC-2732. Adapted from patch by Phil Pennock.
-rw-r--r-- | util/ChangeLog | 3 | ||||
-rw-r--r-- | util/http.c | 23 |
2 files changed, 20 insertions, 6 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index 6c5e7d08b..21132d24d 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,5 +1,8 @@ 2009-03-13 David Shaw <[email protected]> + * 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. diff --git a/util/http.c b/util/http.c index 9acd146ec..5013ae6c1 100644 --- a/util/http.c +++ b/util/http.c @@ -343,16 +343,27 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) } 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; } |