mirror of
https://github.com/ipxe/ipxe
synced 2025-12-09 02:40:27 +03:00
[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>
This commit is contained in:
committed by
Michael Brown
parent
132c391712
commit
4cb0bfe291
@@ -74,8 +74,8 @@ struct uri * parse_uri ( const char *uri_string ) {
|
|||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
char *raw;
|
char *raw;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *path = NULL;
|
char *path;
|
||||||
char *authority = NULL;
|
char *authority;
|
||||||
int i;
|
int i;
|
||||||
size_t raw_len;
|
size_t raw_len;
|
||||||
|
|
||||||
@@ -110,6 +110,7 @@ struct uri * parse_uri ( const char *uri_string ) {
|
|||||||
} else {
|
} else {
|
||||||
/* Absolute URI with opaque part */
|
/* Absolute URI with opaque part */
|
||||||
uri->opaque = tmp;
|
uri->opaque = tmp;
|
||||||
|
path = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Relative URI */
|
/* Relative URI */
|
||||||
@@ -148,8 +149,15 @@ struct uri * parse_uri ( const char *uri_string ) {
|
|||||||
} else {
|
} else {
|
||||||
/* Absolute/relative path */
|
/* Absolute/relative path */
|
||||||
uri->path = 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 */
|
/* Split authority into user[:password] and host[:port] portions */
|
||||||
if ( ( tmp = strchr ( authority, '@' ) ) ) {
|
if ( ( tmp = strchr ( authority, '@' ) ) ) {
|
||||||
/* Has user[:password] */
|
/* Has user[:password] */
|
||||||
|
|||||||
Reference in New Issue
Block a user