From ad8fce0c1b11756e1fe04bf04ff205f18ff5dfad Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 14 Dec 2009 03:28:53 +0100 Subject: [PATCH] Handle additional DNS records when sending alternate request The outbound queries that get qualified with the search domain need to handle additional records. Otherwise ENDS0 and other options might fail. --- plugins/dnsproxy.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c index 9f1c265..8f28214 100644 --- a/plugins/dnsproxy.c +++ b/plugins/dnsproxy.c @@ -610,7 +610,11 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, if (data->domain != NULL) { unsigned char alt[1024]; struct domain_hdr *hdr = (void *) &alt; - int altlen; + int altlen, domlen; + + domlen = strlen(data->domain) + 1; + if (domlen < 5) + continue; alt[0] = req->altid & 0xff; alt[1] = req->altid >> 8; @@ -623,12 +627,12 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, if (altlen < 0) continue; - alt[altlen + 12] = 0x00; - alt[altlen + 13] = 0x01; - alt[altlen + 14] = 0x00; - alt[altlen + 15] = 0x01; + altlen += 12; + + memcpy(alt + altlen, buf + altlen - domlen, + len - altlen + domlen); - err = send(sk, alt, altlen + 12 + 4, 0); + err = send(sk, alt, altlen + 4, 0); req->numserv++; } -- 2.7.4