]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix PROXYv2 header read for TCP connections when no proxied addresses release-1.17.0
authorGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 11 Oct 2022 15:39:30 +0000 (17:39 +0200)
committerGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 11 Oct 2022 15:39:30 +0000 (17:39 +0200)
  are provided.

doc/Changelog
util/netevent.c

index 790d7793f05237d97fbd52ee52191972859ac7f7..727d1543ea4e30c982066aa38ff6f156a4cd5fa9 100644 (file)
@@ -1,3 +1,7 @@
+11 October 2022: George
+       - Fix PROXYv2 header read for TCP connections when no proxied addresses
+         are provided.
+
 7 October 2022: George
        - Fix to stop possible loops in the tcp reuse code (write_wait list
          and tcp_wait list). Based on analysis and patch from Prad Seniappan
index 9e5436b93007268048c2de0954fd44986ba8a16d..da59a9d60bdad9dd53b92e9c8f7051cd22d0be76 100644 (file)
@@ -1694,7 +1694,10 @@ ssl_handle_read(struct comm_point* c)
                                "part of PROXYv2 header (len %lu)",
                                (unsigned long)want_read_size);
                        current_read_size = PP2_HEADER_SIZE + want_read_size;
-                       if(c->tcp_byte_count < current_read_size) {
+                       if(want_read_size == 0) {
+                               /* nothing more to read; header is complete */
+                               c->pp2_header_state = pp2_header_done;
+                       } else if(c->tcp_byte_count < current_read_size) {
                                ERR_clear_error();
                                if((r=SSL_read(c->ssl, (void*)sldns_buffer_at(
                                        c->buffer, c->tcp_byte_count),
@@ -2083,7 +2086,10 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
                                "part of PROXYv2 header (len %lu)",
                                (unsigned long)want_read_size);
                        current_read_size = PP2_HEADER_SIZE + want_read_size;
-                       if(c->tcp_byte_count < current_read_size) {
+                       if(want_read_size == 0) {
+                               /* nothing more to read; header is complete */
+                               c->pp2_header_state = pp2_header_done;
+                       } else if(c->tcp_byte_count < current_read_size) {
                                r = recv(fd, (void*)sldns_buffer_at(c->buffer,
                                        c->tcp_byte_count),
                                        current_read_size-c->tcp_byte_count, MSG_DONTWAIT);