summaryrefslogtreecommitdiff
path: root/usr.bin/nc
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2008-05-09 09:00:12 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2008-05-09 09:00:12 +0000
commit560464fefa0e642036e148c457d95950e83ec1c9 (patch)
treec8c709262b90a2e224922cfec6e6a1ead669e644 /usr.bin/nc
parent362f1c0bc0faa8616843609a3c677684ef9acc14 (diff)
try SO_BINDANY for -s, but do not insist; ok bob, reyk
Diffstat (limited to 'usr.bin/nc')
-rw-r--r--usr.bin/nc/netcat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index 4228326bdd8..48b2b673ba4 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.90 2008/05/06 05:47:39 djm Exp $ */
+/* $OpenBSD: netcat.c,v 1.91 2008/05/09 09:00:11 markus Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -487,7 +487,7 @@ int
remote_connect(const char *host, const char *port, struct addrinfo hints)
{
struct addrinfo *res, *res0;
- int s, error;
+ int s, error, on = 1;
if ((error = getaddrinfo(host, port, &hints, &res)))
errx(1, "getaddrinfo: %s", gai_strerror(error));
@@ -502,6 +502,8 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
if (sflag || pflag) {
struct addrinfo ahints, *ares;
+ /* try SO_BINDANY, but don't insist */
+ setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on));
memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res0->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;