mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Merge branch '4273-streamdns-eagain' into 'main'
Resolve "crash while receiving 64 kiB message over TCP" Closes #4273 See merge request isc-projects/bind9!8231
This commit is contained in:
@@ -114,3 +114,21 @@ def test_close_wait(named_port):
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
|
||||
# GL #4273
|
||||
def test_tcp_big(named_port):
|
||||
with create_socket("10.53.0.7", named_port) as sock:
|
||||
msg = dns.message.Message(id=0)
|
||||
msg.flags = dns.flags.RD
|
||||
msg.question.append(dns.rrset.from_text(dns.name.root, 0, 1, "URI"))
|
||||
msg.additional.append(
|
||||
dns.rrset.from_text(dns.name.root, 0, 1, "URI", "0 0 " + "b" * 65503)
|
||||
)
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
# Now check that the server is alive and well
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
|
@@ -491,13 +491,9 @@ isc_dnsstream_assembler_incoming(isc_dnsstream_assembler_t *restrict dnsasm,
|
||||
REQUIRE(dnsasm != NULL);
|
||||
INSIST(!dnsasm->calling_cb);
|
||||
|
||||
if (buf_size == 0) {
|
||||
INSIST(buf == NULL);
|
||||
} else {
|
||||
if (buf != NULL && buf_size > 0) {
|
||||
size_t remaining;
|
||||
|
||||
INSIST(buf != NULL);
|
||||
|
||||
remaining = isc_buffer_remaininglength(&dnsasm->dnsbuf);
|
||||
|
||||
if (remaining == 0) {
|
||||
@@ -525,7 +521,7 @@ isc_dnsstream_assembler_incoming(isc_dnsstream_assembler_t *restrict dnsasm,
|
||||
* when receiving the next batch of data.
|
||||
*/
|
||||
return;
|
||||
} else if (remaining == 1 && buf_size > 0) {
|
||||
} else if (remaining == 1) {
|
||||
/* Mostly the same case as above, but we have incomplete
|
||||
* message length in the buffer and received at least
|
||||
* one byte to complete it.
|
||||
@@ -544,7 +540,7 @@ isc_dnsstream_assembler_incoming(isc_dnsstream_assembler_t *restrict dnsasm,
|
||||
return;
|
||||
}
|
||||
|
||||
if (buf_size > 0) {
|
||||
if (unprocessed_size > 0) {
|
||||
isc_buffer_putmem(dnsasm->current,
|
||||
unprocessed_buf,
|
||||
unprocessed_size);
|
||||
|
Reference in New Issue
Block a user