[systemd-devel] [PATCH] resolved: avoid possible dereference of null pointer
Thomas H.P. Andersen
phomes at gmail.com
Sun Aug 3 13:53:05 PDT 2014
From: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 9567056..3c2f6e6 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);
--
1.9.3
More information about the systemd-devel
mailing list