Control: tag -1 patch On Fri, 06 Mar 2020 at 17:50:38 +0100, Guilhem Moulin wrote: > Also, calling exit() in fillbuf() is the wrong approach as the buffer > might not have been drained yet.
The enclosed patch seems to work for me. (Untested though, so not pushing just yet.) Since for UDP sockets we won't get revents=POLLIN after calling ‘shutdown(pfd[POLL_NETOUT].fd, SHUT_WR)’, a workaround is to set pfd[POLL_NETIN].fd to -1 as well at the end of readwrite(). -- Guilhem.
--- a/netcat.c
+++ b/netcat.c
@@ -1607,6 +1607,10 @@
if (pfd[POLL_NETOUT].fd != -1 && Nflag)
shutdown(pfd[POLL_NETOUT].fd, SHUT_WR);
pfd[POLL_NETOUT].fd = -1;
+ if (uflag && pfd[POLL_NETIN].fd != -1 && Nflag && netinbufpos == 0) {
+ shutdown(pfd[POLL_NETIN].fd, SHUT_RD);
+ pfd[POLL_NETIN].fd = -1;
+ }
}
/* net in gone and queue empty? */
if (pfd[POLL_NETIN].fd == -1 && netinbufpos == 0) {
signature.asc
Description: PGP signature

