From 7db49828bd974df7d9daaff460898589be5e2a26 Mon Sep 17 00:00:00 2001 From: Pierre Souchay Date: Wed, 18 Apr 2018 14:17:44 +0200 Subject: [PATCH] Fixed sync of Extra in binarySearch --- agent/dns.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agent/dns.go b/agent/dns.go index 599d75822..457674bb1 100644 --- a/agent/dns.go +++ b/agent/dns.go @@ -721,14 +721,17 @@ func syncExtra(index map[string]dns.RR, resp *dns.Msg) { // it in order to return a DNS answer lower than maxSize parameter. func dnsBinaryTruncate(resp *dns.Msg, maxSize int, index map[string]dns.RR, hasExtra bool) int { originalAnswser := resp.Answer + originalExtra := resp.Extra + originalIndex := index startIndex := 0 endIndex := len(resp.Answer) + 1 for endIndex-startIndex > 1 { median := startIndex + (endIndex-startIndex)/2 resp.Answer = originalAnswser[:median] - resp.Extra = originalAnswser[:median] if hasExtra { + resp.Extra = originalExtra[:median] + index := originalIndex syncExtra(index, resp) } aLen := resp.Len()