summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2014-08-03 22:41:25 +0200
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2014-08-03 23:01:57 +0200
commit75cd513ef830d8e00d0d2d6a64917fec533315db (patch)
tree1cc3c0e742b896de8816d22ce26d1d98d7123580
parent621ac3d2cc8f37169166df9c7f379b0cb6b17e36 (diff)
resolved: avoid possible dereference of null pointer
In dns_scope_make_reply_packet the structs q, answer, and soa can be null. We should check for null before reading their fields.
-rw-r--r--src/resolve/resolved-dns-scope.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 8d03049c10..0f654a6102 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -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);