summaryrefslogtreecommitdiff
path: root/usr.bin/nc/netcat.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2016-05-28 19:39:17 +0000
committerBob Beck <beck@cvs.openbsd.org>2016-05-28 19:39:17 +0000
commitd3bd58da108c380d32cb28c54dcc66ff1f522c19 (patch)
treef8663a04affdd1d25f57f834e0d962db185f3cbc /usr.bin/nc/netcat.c
parent96c3eaa08b60661c644e79c04ec3e8298e0c236e (diff)
Fix nc -verbose mode when used on a unix domain socket.
Noticed by and a modified version of fix from <attila@stalphonsos.com>
Diffstat (limited to 'usr.bin/nc/netcat.c')
-rw-r--r--usr.bin/nc/netcat.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index 8bbd183e622..1b22308d5a2 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.150 2016/01/04 02:18:31 bcook Exp $ */
+/* $OpenBSD: netcat.c,v 1.151 2016/05/28 19:39:16 beck Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
* Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -133,7 +133,7 @@ int unix_listen(char *);
void set_common_sockopts(int, int);
int map_tos(char *, int *);
int map_tls(char *, int *);
-void report_connect(const struct sockaddr *, socklen_t);
+void report_connect(const struct sockaddr *, socklen_t, char *);
void report_tls(struct tls *tls_ctx, char * host, char *tls_expectname);
void usage(int);
ssize_t drainbuf(int, unsigned char *, size_t *, struct tls *);
@@ -516,7 +516,7 @@ main(int argc, char *argv[])
err(1, "connect");
if (vflag)
- report_connect((struct sockaddr *)&z, len);
+ report_connect((struct sockaddr *)&z, len, NULL);
readwrite(s, NULL);
} else {
@@ -528,7 +528,8 @@ main(int argc, char *argv[])
err(1, "accept");
}
if (vflag)
- report_connect((struct sockaddr *)&cliaddr, len);
+ report_connect((struct sockaddr *)&cliaddr, len,
+ family == AF_UNIX ? host : NULL);
if ((usetls) &&
(tls_cctx = tls_setup_server(tls_ctx, connfd, host)))
readwrite(connfd, tls_cctx);
@@ -1487,13 +1488,18 @@ report_tls(struct tls * tls_ctx, char * host, char *tls_expectname)
}
void
-report_connect(const struct sockaddr *sa, socklen_t salen)
+report_connect(const struct sockaddr *sa, socklen_t salen, char *path)
{
char remote_host[NI_MAXHOST];
char remote_port[NI_MAXSERV];
int herr;
int flags = NI_NUMERICSERV;
+ if (path != NULL) {
+ fprintf(stderr, "Connection on %s received!\n", path);
+ return;
+ }
+
if (nflag)
flags |= NI_NUMERICHOST;