From: Peter Meerwald <[email protected]>

fix a crash because cache is NULL; this happens often, not always
on the first name to resolve

initialization of the cache happens all over the place

cache_update() already has a create_cache() in a special-case path,
but not in the main path

observed with 1.19; may have to do with provisioning config

connmand[4347]: src/network.c:connman_network_unref_debug() 0xc97b0 name Wired 
ref 3 by src/network.c:462:check_dhcpv6()
connmand[4347]: src/ntp.c:send_timeout() send timeout (retries 1)
connmand[4347]: src/ntp.c:send_timeout() send timeout (retries 2)
connmand[4347]: src/ntp.c:send_timeout() send timeout (retries 3)
connmand[4347]: src/ntp.c:__connman_ntp_stop()
connmand[4347]: src/dnsproxy.c:udp_listener_event() Received 27 bytes (id 
0x76ea)
connmand[4347]: src/dnsproxy.c:parse_request() id 0x76ea qr 0 opcode 0 qdcount 
1 arcount 0
connmand[4347]: src/dnsproxy.c:parse_request() query google.at.
connmand[4347]: src/dnsproxy.c:resolv() server 192.168.233.10 enabled 1
connmand[4347]: src/dnsproxy.c:forward_dns_reply() Received 189 bytes (id 
0x2d11)
connmand[4347]: src/dnsproxy.c:forward_dns_reply() req 0xc81c0 dstid 0x2d11 
altid 0xf6ca rcode 0
connmand[4347]: src/dnsproxy.c:cache_update() offset 0 hdr 0xbe828b88 msg 
0xbe828b88 rcode 0
connmand[4347]: src/dnsproxy.c:parse_response() qr 1 qdcount 1
connmand[4347]: Aborting (signal 11) [/usr/sbin/connmand]
---
 src/dnsproxy.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 65806ca..9b7f05d 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1402,6 +1402,9 @@ static int cache_update(struct server_data *srv, unsigned 
char *msg,
        if (hdr->rcode != 0)
                return 0;
 
+       if (!cache)
+               create_cache();
+
        rsplen = sizeof(response) - 1;
        question[sizeof(question) - 1] = '\0';
 
@@ -1418,11 +1421,7 @@ static int cache_update(struct server_data *srv, 
unsigned char *msg,
        if ((err == -ENOMSG || err == -ENOBUFS) &&
                        reply_query_type(msg + offset,
                                        msg_len - offset) == 28) {
-               if (!cache) {
-                       create_cache();
-                       entry = NULL;
-               } else
-                       entry = g_hash_table_lookup(cache, question);
+               entry = g_hash_table_lookup(cache, question);
                if (entry && entry->ipv4 && !entry->ipv6) {
                        int cache_offset = 0;
 
-- 
1.7.9.5

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to