]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
ignore 0-byte reads in the TCP read callback 12261/head
authorAydın Mercan <aydin@isc.org>
Thu, 11 Jun 2026 13:38:27 +0000 (16:38 +0300)
committerAydın Mercan <aydin@isc.org>
Mon, 22 Jun 2026 06:33:38 +0000 (09:33 +0300)
Callbacks for libuv stream reads do not signal zero-length reads as a
failure signal but rather as EAGAIN/EWOULDBLOCK. This can trigger an
assertion when a zero-length read is pushed onto a PROXYv2 endpoint that
has not yet processed the headers as it expects a non-NULL region of
positive length.

lib/isc/netmgr/tcp.c

index 9d50d98e1a48e3bd009eab28c3860d24dcb7d527..9ec8a7f3b5d0a900a2d7fc236cf7ebfe28bead27 100644 (file)
@@ -778,7 +778,10 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
                goto free;
        }
 
-       if (nread < 0) {
+       if (nread == 0) {
+               /* EAGAIN/EWOULDBLOCK: no data yet, not an error on libuv. */
+               goto free;
+       } else if (nread < 0) {
                if (nread != UV_EOF) {
                        isc__nm_incstats(sock, STATID_RECVFAIL);
                }
@@ -837,7 +840,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
        }
 
 free:
-       if (nread < 0) {
+       if (nread <= 0) {
                /*
                 * The buffer may be a null buffer on error.
                 */