summaryrefslogtreecommitdiff
path: root/src/dnsproxy.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-06-20 13:38:39 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-06-20 14:11:39 +0300
commit1055cd4d6e435cf32c0597518129b6ec48d9c844 (patch)
tree3f4be2f5f1b463b0750fccdbbd9f96cef989d624 /src/dnsproxy.c
parentc7af063414315eecfb76cc99d07f19b5357e4b94 (diff)
downloadconnman-1055cd4d6e435cf32c0597518129b6ec48d9c844.tar.gz
connman-1055cd4d6e435cf32c0597518129b6ec48d9c844.tar.bz2
connman-1055cd4d6e435cf32c0597518129b6ec48d9c844.zip
dnsproxy: Use DNS header in checks
We should use the DNS header struct when checking DNS protocol values instead of using pointer so that the TCP offset is properly taken care of.
Diffstat (limited to 'src/dnsproxy.c')
-rw-r--r--src/dnsproxy.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index e7123f1c..dc8ab13e 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1246,6 +1246,7 @@ static int cache_update(struct server_data *srv, unsigned char *msg,
int offset = protocol_offset(srv->protocol);
int err, qlen, ttl = 0;
uint16_t answers = 0, type = 0, class = 0;
+ struct domain_hdr *hdr = (void *)(msg + offset);
struct domain_question *q;
struct cache_entry *entry;
struct cache_data *data;
@@ -1270,12 +1271,13 @@ static int cache_update(struct server_data *srv, unsigned char *msg,
next_refresh = current_time + 30;
}
-
- /* Continue only if response code is 0 (=ok) */
- if (msg[3] & 0x0f)
+ if (offset < 0)
return 0;
- if (offset < 0)
+ DBG("offset %d hdr %p msg %p rcode %d", offset, hdr, msg, hdr->rcode);
+
+ /* Continue only if response code is 0 (=ok) */
+ if (hdr->rcode != 0)
return 0;
rsplen = sizeof(response) - 1;
@@ -1303,7 +1305,7 @@ static int cache_update(struct server_data *srv, unsigned char *msg,
return -ENOMEM;
data->inserted = entry->ipv4->inserted;
data->type = type;
- data->answers = msg[5];
+ data->answers = hdr->ancount;
data->timeout = entry->ipv4->timeout;
if (srv->protocol == IPPROTO_UDP)
cache_offset = 2;