Skip to content

Commit

Permalink
[uri] Fix NULL dereference in parse_uri()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pjaroszynski authored and mcb30 committed Apr 25, 2010
1 parent 132c391 commit 4cb0bfe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/uri.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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] */
Expand Down

0 comments on commit 4cb0bfe

Please sign in to comment.