mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-12 20:24:04 +02:00
resolver: Return error looking up invalid hostnames
Make g_resolver_lookup_by_name() and g_resolver_lookup_by_name_async() error out when invalid hostnames are passed. https://bugzilla.gnome.org/show_bug.cgi?id=772989
This commit is contained in:
@@ -403,6 +403,13 @@ g_resolver_lookup_by_name (GResolver *resolver,
|
|||||||
if (g_hostname_is_non_ascii (hostname))
|
if (g_hostname_is_non_ascii (hostname))
|
||||||
hostname = ascii_hostname = g_hostname_to_ascii (hostname);
|
hostname = ascii_hostname = g_hostname_to_ascii (hostname);
|
||||||
|
|
||||||
|
if (!hostname)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
_("Invalid hostname"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_resolver_maybe_reload (resolver);
|
g_resolver_maybe_reload (resolver);
|
||||||
addrs = G_RESOLVER_GET_CLASS (resolver)->
|
addrs = G_RESOLVER_GET_CLASS (resolver)->
|
||||||
lookup_by_name (resolver, hostname, cancellable, error);
|
lookup_by_name (resolver, hostname, cancellable, error);
|
||||||
@@ -460,6 +467,19 @@ g_resolver_lookup_by_name_async (GResolver *resolver,
|
|||||||
if (g_hostname_is_non_ascii (hostname))
|
if (g_hostname_is_non_ascii (hostname))
|
||||||
hostname = ascii_hostname = g_hostname_to_ascii (hostname);
|
hostname = ascii_hostname = g_hostname_to_ascii (hostname);
|
||||||
|
|
||||||
|
if (!hostname)
|
||||||
|
{
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
_("Invalid hostname"));
|
||||||
|
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||||
|
g_task_set_source_tag (task, g_resolver_lookup_by_name_async);
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_resolver_maybe_reload (resolver);
|
g_resolver_maybe_reload (resolver);
|
||||||
G_RESOLVER_GET_CLASS (resolver)->
|
G_RESOLVER_GET_CLASS (resolver)->
|
||||||
lookup_by_name_async (resolver, hostname, cancellable, callback, user_data);
|
lookup_by_name_async (resolver, hostname, cancellable, callback, user_data);
|
||||||
|
Reference in New Issue
Block a user