dns: fix remaining-space tracking when copying address records (#13558)
When decoding a DNS response, the path that copies an unaligned A or AAAA
record into the host entry buffer moved the write position without updating
the count of space remaining, so the two disagreed for the rest of the
response. Update the count after the copy, the same way the name, CNAME and
PTR paths already do.
diff --git a/src/iocore/dns/DNS.cc b/src/iocore/dns/DNS.cc
index 4c6cecd..16e33e9 100644
--- a/src/iocore/dns/DNS.cc
+++ b/src/iocore/dns/DNS.cc
@@ -1889,8 +1889,9 @@
memcpy((*hap++ = bp), cp, n);
Dbg(dbg_ctl_dns, "received %s = %s", QtypeName(type),
inet_ntop(T_AAAA == type ? AF_INET6 : AF_INET, bp, ip_string, sizeof(ip_string)));
- bp += n;
- cp += n;
+ bp += n;
+ cp += n;
+ buflen = sizeof(buf->hostbuf) - (bp - buf->hostbuf);
}
} else {
goto Lerror;