mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
networkaddress: Add early sanity check to _g_uri_parse_authority()
Check whether the URI is valid ASCII before trying to parse it. This should catch broken URIs early. https://bugzilla.gnome.org/show_bug.cgi?id=772989
This commit is contained in:
parent
5f2c20e88b
commit
99b792fac0
@ -492,7 +492,7 @@ _g_uri_parse_authority (const char *uri,
|
||||
char **userinfo,
|
||||
GError **error)
|
||||
{
|
||||
char *tmp_str;
|
||||
char *ascii_uri, *tmp_str;
|
||||
const char *start, *p, *at, *delim;
|
||||
char c;
|
||||
|
||||
@ -507,6 +507,11 @@ _g_uri_parse_authority (const char *uri,
|
||||
if (userinfo)
|
||||
*userinfo = NULL;
|
||||
|
||||
/* Catch broken URIs early by trying to convert to ASCII. */
|
||||
ascii_uri = g_hostname_to_ascii (uri);
|
||||
if (!ascii_uri)
|
||||
goto error;
|
||||
|
||||
/* From RFC 3986 Decodes:
|
||||
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
|
||||
* hier-part = "//" authority path-abempty
|
||||
@ -515,7 +520,7 @@ _g_uri_parse_authority (const char *uri,
|
||||
*/
|
||||
|
||||
/* Check we have a valid scheme */
|
||||
tmp_str = g_uri_parse_scheme (uri);
|
||||
tmp_str = g_uri_parse_scheme (ascii_uri);
|
||||
|
||||
if (tmp_str == NULL)
|
||||
goto error;
|
||||
@ -525,7 +530,7 @@ _g_uri_parse_authority (const char *uri,
|
||||
/* Decode hier-part:
|
||||
* hier-part = "//" authority path-abempty
|
||||
*/
|
||||
p = uri;
|
||||
p = ascii_uri;
|
||||
start = strstr (p, "//");
|
||||
|
||||
if (start == NULL)
|
||||
@ -715,6 +720,8 @@ error:
|
||||
*userinfo = NULL;
|
||||
}
|
||||
|
||||
g_free (ascii_uri);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user