]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix RFC7766 compliance when client sends EOF over TCP. It stops
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 15 Apr 2026 09:29:07 +0000 (11:29 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 15 Apr 2026 09:29:07 +0000 (11:29 +0200)
  pending replies and closes. Thanks to Yuxiao Wu, Tsinghua
  University for the report.

doc/Changelog
services/listen_dnsport.c
testdata/fwd_compress_c00c.tdir/fwd_compress_c00c.test

index c9052de9c1f1fcd55b50cd88be1a869a40991d7e..9c96a9fc977eda04bac94b00100f8e6d06e21511 100644 (file)
@@ -1,3 +1,8 @@
+15 April 2026: Wouter
+       - Fix RFC7766 compliance when client sends EOF over TCP. It stops
+         pending replies and closes. Thanks to Yuxiao Wu, Tsinghua
+         University for the report.
+
 14 April 2026: Wouter
        - Fix #1017: memory corruption related core dumps.
          When alloc_reg_obtain has an empty list, return a new allocation.
index 9971f9e2e48768577c98739c96b3e815b209c326..97a7c84b2c30171a64c14078f04d340e8a5c87c0 100644 (file)
@@ -2300,21 +2300,8 @@ int
 tcp_req_info_handle_read_close(struct tcp_req_info* req)
 {
        verbose(VERB_ALGO, "tcp channel read side closed %d", req->cp->fd);
-       /* reset byte count for (potential) partial read */
-       req->cp->tcp_byte_count = 0;
-       /* if we still have results to write, pick up next and write it */
-       if(req->num_done_req != 0) {
-               tcp_req_pickup_next_result(req);
-               tcp_req_info_setup_listen(req);
-               return 1;
-       }
-       /* if nothing to do, this closes the connection */
-       if(req->num_open_req == 0 && req->num_done_req == 0)
-               return 0;
-       /* otherwise, we must be waiting for dns resolve, wait with timeout */
-       req->read_is_closed = 1;
-       tcp_req_info_setup_listen(req);
-       return 1;
+       /* RFC 7766 6.2.4 says to drop pending replies when client closes. */
+       return 0; /* drop connection */
 }
 
 void
index de4250c3e9eba98973ab4846db221702ea950dec..4c25b80f870894fc618a90f927a9d47e3d89a252 100644 (file)
@@ -8,7 +8,7 @@
 if nc -h 2>&1 | grep "q secs"; then
        ncopt="-q 3 -i 2"
 else
-       ncopt="-i 2"
+       ncopt="-i 2 --no-shutdown"
 fi
 
 PRE="../.."