From: Piotr JaroszyĆski
Date: Mon, 12 Apr 2010 15:15:44 +0000 (+0200)
Subject: [uri] Fix NULL dereference in parse_uri()
X-Git-Tag: v1.20.1~2691
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cb0bfe2916eb4252a38bdb300fb59619c5d9f9b;p=thirdparty%2Fipxe.git
[uri] Fix NULL dereference in parse_uri()
Don't try to parse authority if it's not there.
Modified-by: Michael Brown
Signed-off-by: Michael Brown
---
diff --git a/src/core/uri.c b/src/core/uri.c
index 57502f26e..ff49e47a5 100644
--- a/src/core/uri.c
+++ b/src/core/uri.c
@@ -74,8 +74,8 @@ struct uri * parse_uri ( const char *uri_string ) {
struct uri *uri;
char *raw;
char *tmp;
- char *path = NULL;
- char *authority = NULL;
+ char *path;
+ char *authority;
int i;
size_t raw_len;
@@ -110,6 +110,7 @@ struct uri * parse_uri ( const char *uri_string ) {
} else {
/* Absolute URI with opaque part */
uri->opaque = tmp;
+ path = NULL;
}
} else {
/* Relative URI */
@@ -148,8 +149,15 @@ struct uri * parse_uri ( const char *uri_string ) {
} else {
/* Absolute/relative path */
uri->path = path;
+ authority = NULL;
}
+ /* If we don't have an authority (i.e. we have a non-net
+ * path), we're already finished processing
+ */
+ if ( ! authority )
+ goto done;
+
/* Split authority into user[:password] and host[:port] portions */
if ( ( tmp = strchr ( authority, '@' ) ) ) {
/* Has user[:password] */