瀏覽代碼

[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 年之前
父節點
當前提交
4cb0bfe291
共有 1 個檔案被更改,包括 10 行新增2 行删除
  1. 10
    2
      src/core/uri.c

+ 10
- 2
src/core/uri.c 查看文件

74
 	struct uri *uri;
74
 	struct uri *uri;
75
 	char *raw;
75
 	char *raw;
76
 	char *tmp;
76
 	char *tmp;
77
-	char *path = NULL;
78
-	char *authority = NULL;
77
+	char *path;
78
+	char *authority;
79
 	int i;
79
 	int i;
80
 	size_t raw_len;
80
 	size_t raw_len;
81
 
81
 
110
 		} else {
110
 		} else {
111
 			/* Absolute URI with opaque part */
111
 			/* Absolute URI with opaque part */
112
 			uri->opaque = tmp;
112
 			uri->opaque = tmp;
113
+			path = NULL;
113
 		}
114
 		}
114
 	} else {
115
 	} else {
115
 		/* Relative URI */
116
 		/* Relative URI */
148
 	} else {
149
 	} else {
149
 		/* Absolute/relative path */
150
 		/* Absolute/relative path */
150
 		uri->path = path;
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
 	/* Split authority into user[:password] and host[:port] portions */
161
 	/* Split authority into user[:password] and host[:port] portions */
154
 	if ( ( tmp = strchr ( authority, '@' ) ) ) {
162
 	if ( ( tmp = strchr ( authority, '@' ) ) ) {
155
 		/* Has user[:password] */
163
 		/* Has user[:password] */

Loading…
取消
儲存