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.
This commit is contained in:
Thomas Hindoe Paaboel Andersen
2014-08-03 23:01:57 +02:00
parent 621ac3d2cc
commit 75cd513ef8
+3 -1
View 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);