summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-06-16 16:22:33 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-06-16 16:22:33 +0200
commit51de7bc59bb05f965d493b03dd66ba22d126a753 (patch)
tree908de5cfb997e98e4a822cf43b0fdbe8559d7db6
parent127639e998a56ae30f3cbea9359748ab807ed2a1 (diff)
downloadconnman-51de7bc59bb05f965d493b03dd66ba22d126a753.tar.gz
Remove magic constants from dns request parsing code
-rw-r--r--plugins/dnsproxy.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c
index 5a77c5fc..2cb2f41f 100644
--- a/plugins/dnsproxy.c
+++ b/plugins/dnsproxy.c
@@ -401,6 +401,8 @@ static struct connman_notifier dnsproxy_notifier = {
.offline_mode = dnsproxy_offline_mode,
};
+static unsigned char opt_edns0_type[2] = { 0x00, 0x29 };
+
static int parse_request(unsigned char *buf, int len,
char *name, unsigned int size)
{
@@ -423,8 +425,8 @@ static int parse_request(unsigned char *buf, int len,
memset(name, 0, size);
- ptr = buf + 12;
- remain = len - 12;
+ ptr = buf + sizeof(struct domain_hdr);
+ remain = len - sizeof(struct domain_hdr);
while (remain > 0) {
uint8_t len = *ptr;
@@ -447,7 +449,7 @@ static int parse_request(unsigned char *buf, int len,
}
if (last_label && arcount && remain >= 9 && last_label[4] == 0 &&
- last_label[5] == 0 && last_label[6] == 0x29) {
+ !memcmp(last_label + 5, opt_edns0_type, 2)) {
uint16_t edns0_bufsize;
edns0_bufsize = last_label[7] << 8 | last_label[8];