]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Fixed testns infinite loop on closed TCP channels.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 20 Jan 2014 15:20:55 +0000 (16:20 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 20 Jan 2014 15:20:55 +0000 (16:20 +0100)
examples/ldns-testns.c

index f9732faaf07e244aba7c3e220bb7cb9554221eca..05c28e1c9940b3110646e7c05a2a269d5f7f028e 100644 (file)
@@ -280,6 +280,10 @@ read_n_bytes(int sock, uint8_t* buf, size_t sz)
                if(nb < 0) {
                        log_msg("recv(): %s\n", strerror(errno));
                        return;
+               } else if(nb == 0) {
+                       log_msg("recv: remote end closed the channel\n");
+                       memset(buf+count, 0, sz-count);
+                       return;
                }
                count += nb;
        }