]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Combine write of tcp length and tcp query for dns over tls.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Apr 2018 08:10:25 +0000 (08:10 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Apr 2018 08:10:25 +0000 (08:10 +0000)
git-svn-id: file:///svn/unbound/trunk@4601 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/netevent.c

index 25e8d308f95df2430d08b1a5b09964739f9f4559..df5c20b50561040a9c445089cb604684a841ef4c 100644 (file)
@@ -1,3 +1,6 @@
+5 April 2018: Wouter
+       - Combine write of tcp length and tcp query for dns over tls.
+
 3 April 2018: Wouter
        - Fix #4043: make test fails due to v6 presentation issue in macOS.
        - Fix unable to resolve after new WLAN connection, due to auth-zone
index fc6f6a9ea8b52a39a50817ec92d60b21ee1d7724..f0d72e038441ebe2161cb98b9a1f67162b28c5d8 100644 (file)
@@ -46,6 +46,7 @@
 #include "util/fptr_wlist.h"
 #include "sldns/pkthdr.h"
 #include "sldns/sbuffer.h"
+#include "sldns/str2wire.h"
 #include "dnstap/dnstap.h"
 #include "dnscrypt/dnscrypt.h"
 #ifdef HAVE_OPENSSL_SSL_H
@@ -1209,9 +1210,24 @@ ssl_handle_write(struct comm_point* c)
        if(c->tcp_byte_count < sizeof(uint16_t)) {
                uint16_t len = htons(sldns_buffer_limit(c->buffer));
                ERR_clear_error();
-               r = SSL_write(c->ssl,
-                       (void*)(((uint8_t*)&len)+c->tcp_byte_count),
-                       (int)(sizeof(uint16_t)-c->tcp_byte_count));
+               if(sizeof(uint16_t)+sldns_buffer_remaining(c->buffer) <
+                       LDNS_RR_BUF_SIZE) {
+                       /* combine the tcp length and the query for write,
+                        * this emulates writev */
+                       uint8_t buf[LDNS_RR_BUF_SIZE];
+                       memmove(buf, &len, sizeof(uint16_t));
+                       memmove(buf+sizeof(uint16_t),
+                               sldns_buffer_current(c->buffer),
+                               sldns_buffer_remaining(c->buffer));
+                       r = SSL_write(c->ssl, (void*)(buf+c->tcp_byte_count),
+                               (int)(sizeof(uint16_t)+
+                               sldns_buffer_remaining(c->buffer)
+                               - c->tcp_byte_count));
+               } else {
+                       r = SSL_write(c->ssl,
+                               (void*)(((uint8_t*)&len)+c->tcp_byte_count),
+                               (int)(sizeof(uint16_t)-c->tcp_byte_count));
+               }
                if(r <= 0) {
                        int want = SSL_get_error(c->ssl, r);
                        if(want == SSL_ERROR_ZERO_RETURN) {