diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-06-20 13:38:37 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-06-20 14:11:19 +0300 |
commit | 3dabff35b045357620740e0497b7c0445174057c (patch) | |
tree | 8c4333cb3097b8ca816ad2b38674f6b03b3e98d7 /src | |
parent | 5838fb5a1bff387b8b7c4f50feda6e095f06ddf8 (diff) | |
download | connman-3dabff35b045357620740e0497b7c0445174057c.tar.gz connman-3dabff35b045357620740e0497b7c0445174057c.tar.bz2 connman-3dabff35b045357620740e0497b7c0445174057c.zip |
dnsproxy: Check cache properly for TCP packets
The DNS packet starts from offset 2 in TCP payload.
Diffstat (limited to 'src')
-rw-r--r-- | src/dnsproxy.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/dnsproxy.c b/src/dnsproxy.c index f309d0dd..d5c77f75 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -665,13 +665,22 @@ static uint16_t cache_check_validity(char *question, uint16_t type, return type; } -static struct cache_entry *cache_check(gpointer request, int *qtype) +static struct cache_entry *cache_check(gpointer request, int *qtype, int proto) { - char *question = request + 12; + char *question; struct cache_entry *entry; struct domain_question *q; uint16_t type; - int offset; + int offset, proto_offset; + + if (request == NULL) + return NULL; + + proto_offset = protocol_offset(proto); + if (proto_offset < 0) + return NULL; + + question = request + proto_offset + 12; offset = strlen(question) + 1; q = (void *) (question + offset); @@ -1457,7 +1466,7 @@ static int ns_resolv(struct server_data *server, struct request_data *req, char *dot, *lookup = (char *) name; struct cache_entry *entry; - entry = cache_check(request, &type); + entry = cache_check(request, &type, req->protocol); if (entry != NULL) { int ttl_left = 0; struct cache_data *data; |