dns: use different buffers for encoding and decoding names
authorSteven Barth <steven@midlink.org>
Tue, 28 Oct 2014 18:41:13 +0000 (19:41 +0100)
committerSteven Barth <steven@midlink.org>
Wed, 29 Oct 2014 15:24:21 +0000 (16:24 +0100)
dns_send_question was ocassionally called with a name from name_buf

Signed-off-by: Steven Barth <steven@midlink.org>
dns.c

diff --git a/dns.c b/dns.c
index c5323e5e93c449af5ff38913dc8ec5c6a6a18687..89cd4ce5a76fc4ebd736784cf6d6fcbe4180bf0d 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -39,6 +39,7 @@
 #include "interface.h"
 
 static char name_buffer[MAX_NAME_LEN + 1];
+static char dns_buffer[MAX_NAME_LEN];
 static struct blob_buf ans_buf;
 
 const char*
@@ -76,7 +77,7 @@ dns_send_question(struct interface *iface, const char *question, int type, int u
                        .iov_len = sizeof(h),
                },
                {
-                       .iov_base = name_buffer,
+                       .iov_base = dns_buffer,
                },
                {
                        .iov_base = &q,
@@ -89,7 +90,7 @@ dns_send_question(struct interface *iface, const char *question, int type, int u
        q.class = cpu_to_be16(((unicast) ? (CLASS_UNICAST) : (0))  | 1);
        q.type = cpu_to_be16(type);
 
-       len = dn_comp(question, (void *) name_buffer, sizeof(name_buffer), NULL, NULL);
+       len = dn_comp(question, (void *) dns_buffer, sizeof(dns_buffer), NULL, NULL);
        if (len < 1)
                return;