[glib/glib-2-40] gresolver: Ensure GThreadedResolver always sets an error if resolution fails



commit 466076bfd6c863e5b4d0ba956e587fdeeb917b78
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Apr 24 09:26:12 2014 +0100

    gresolver: Ensure GThreadedResolver always sets an error if resolution fails
    
    It was previously possible for GThreadedResolver to return an empty list
    and no error in response to a g_resolver_lookup_by_name() call, if it
    happened that all the addresses returned by getaddrinfo() could not be
    converted from native addresses to GSocketAddresses.
    
    Fix that by setting a G_RESOLVER_ERROR_NOT_FOUND if the returned list is
    empty.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728776

 gio/gthreadedresolver.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
index 3bb4d08..7b13bba 100644
--- a/gio/gthreadedresolver.c
+++ b/gio/gthreadedresolver.c
@@ -96,9 +96,21 @@ do_lookup_by_name (GTask         *task,
           g_object_unref (sockaddr);
         }
 
-      addresses = g_list_reverse (addresses);
-      g_task_return_pointer (task, addresses,
-                             (GDestroyNotify)g_resolver_free_addresses);
+      if (addresses != NULL)
+        {
+          addresses = g_list_reverse (addresses);
+          g_task_return_pointer (task, addresses,
+                                 (GDestroyNotify)g_resolver_free_addresses);
+        }
+      else
+        {
+          /* All addresses failed to be converted to GSocketAddresses. */
+          g_task_return_new_error (task,
+                                   G_RESOLVER_ERROR,
+                                   G_RESOLVER_ERROR_NOT_FOUND,
+                                   _("No DNS record of the requested type for '%s'"),
+                                   hostname);
+        }
     }
   else
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]