On 12/02/2014 00:15, Ted Unangst wrote:
I think the patch is broken though. It should add a close() if !kflag.
Attaching an updated patch that fixes the problem minimally for -l.
However, as I noted before, the code there has some redundant logic of
closing the listening socket under different options, when closing
should be purely based on -k.
Yuri
--- src/usr.bin/nc/netcat.c
+++ src/usr.bin/nc/netcat.c
@@ -403,13 +403,15 @@
if (vflag)
report_connect((struct sockaddr *)&cliaddr, len);
+ close(s);
+
readwrite(connfd);
close(connfd);
}
- if (family != AF_UNIX)
+ if (family != AF_UNIX && uflag)
close(s);
- else if (uflag) {
+ if (family == AF_UNIX && uflag) {
if (connect(s, NULL, 0) < 0)
err(1, "connect");
}