chiark / gitweb /
resolved: avoid possible dereference of null pointer
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Sun, 3 Aug 2014 20:41:25 +0000 (22:41 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Sun, 3 Aug 2014 21:01:57 +0000 (23:01 +0200)
In dns_scope_make_reply_packet the structs q, answer, and soa can be
null. We should check for null before reading their fields.

src/resolve/resolved-dns-scope.c

index 8d03049c103aec8e3eb867faa5533b2cb8046176..0f654a6102bf2efff85de7670d068e43bd34f9ed 100644 (file)
@@ -412,7 +412,9 @@ static int dns_scope_make_reply_packet(
 
         assert(s);
 
-        if (q->n_keys <= 0 && answer->n_rrs <= 0 && soa->n_rrs <= 0)
+        if ((!q || q->n_keys <= 0)
+            && (!answer || answer->n_rrs <= 0)
+            && (!soa || soa->n_rrs <= 0))
                 return -EINVAL;
 
         r = dns_packet_new(&p, s->protocol, 0);