GThreadedResolver: set an error if no records could be found
authorGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 29 Mar 2013 14:39:26 +0000 (15:39 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 9 Jun 2013 22:07:09 +0000 (18:07 -0400)
It is possible that the upstream servers return something, but
we then filter all results because they are of the wrong type.
In that case the API and subsequent GTask calls expect a GError
to be set.

https://bugzilla.gnome.org/show_bug.cgi?id=696857

gio/gthreadedresolver.c

index def85b8..2332adf 100644 (file)
@@ -472,6 +472,14 @@ g_resolver_records_from_res_query (const gchar      *rrname,
         records = g_list_prepend (records, record);
     }
 
+  if (records == NULL)
+    {
+      g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
+                   _("No DNS record of the requested type for '%s'"), rrname);
+
+      return NULL;
+    }
+  else
     return records;
 }
 
@@ -616,7 +624,15 @@ g_resolver_records_from_DnsQuery (const gchar  *rrname,
         records = g_list_prepend (records, g_variant_ref_sink (record));
     }
 
-  return records;
+  if (records == NULL)
+    {
+      g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
+                   _("No DNS record of the requested type for '%s'"), rrname);
+
+      return NULL;
+    }
+  else
+    return records;
 }
 
 #endif