[glib] resolver: Return error looking up invalid hostnames
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] resolver: Return error looking up invalid hostnames
- Date: Tue, 3 Jan 2017 13:36:54 +0000 (UTC)
commit 442b7ce899df1c0adbbf51bef40dd09b0fd70a51
Author: Bastien Nocera <hadess hadess net>
Date: Wed Dec 7 17:44:08 2016 +0100
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
gio/gresolver.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gio/gresolver.c b/gio/gresolver.c
index 3b4e6c4..3b4f174 100644
--- a/gio/gresolver.c
+++ b/gio/gresolver.c
@@ -403,6 +403,13 @@ g_resolver_lookup_by_name (GResolver *resolver,
if (g_hostname_is_non_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);
addrs = G_RESOLVER_GET_CLASS (resolver)->
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))
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_GET_CLASS (resolver)->
lookup_by_name_async (resolver, hostname, cancellable, callback, user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]