Fixed sync of Extra in binarySearch

This commit is contained in:
Pierre Souchay 2018-04-18 14:17:44 +02:00
parent 615faf9196
commit 7db49828bd
1 changed files with 4 additions and 1 deletions

View File

@ -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()