Bläddra i källkod

[uri] Fix NULL dereference in parse_uri()

Don't try to parse authority if it's not there.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 år sedan
förälder
incheckning
4cb0bfe291
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10
    2
      src/core/uri.c

+ 10
- 2
src/core/uri.c Visa fil

@@ -74,8 +74,8 @@ struct uri * parse_uri ( const char *uri_string ) {
74 74
 	struct uri *uri;
75 75
 	char *raw;
76 76
 	char *tmp;
77
-	char *path = NULL;
78
-	char *authority = NULL;
77
+	char *path;
78
+	char *authority;
79 79
 	int i;
80 80
 	size_t raw_len;
81 81
 
@@ -110,6 +110,7 @@ struct uri * parse_uri ( const char *uri_string ) {
110 110
 		} else {
111 111
 			/* Absolute URI with opaque part */
112 112
 			uri->opaque = tmp;
113
+			path = NULL;
113 114
 		}
114 115
 	} else {
115 116
 		/* Relative URI */
@@ -148,8 +149,15 @@ struct uri * parse_uri ( const char *uri_string ) {
148 149
 	} else {
149 150
 		/* Absolute/relative path */
150 151
 		uri->path = path;
152
+		authority = NULL;
151 153
 	}
152 154
 
155
+	/* If we don't have an authority (i.e. we have a non-net
156
+	 * path), we're already finished processing
157
+	 */
158
+	if ( ! authority )
159
+		goto done;
160
+
153 161
 	/* Split authority into user[:password] and host[:port] portions */
154 162
 	if ( ( tmp = strchr ( authority, '@' ) ) ) {
155 163
 		/* Has user[:password] */

Laddar…
Avbryt
Spara