netcat-openbsd/port-select-on-connect.patch
Peter Simons 62c2516608 Accepting request 853586 from home:elvigia:branches:network:utilities
- Add port-select-on-connect.patch: if -s is given but not -p
  do not select port at bind() but at connect() time.

OBS-URL: https://build.opensuse.org/request/show/853586
OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=22
2020-12-07 13:37:45 +00:00

17 lines
636 B
Diff

Index: netcat-openbsd-1.203/netcat.c
===================================================================
--- netcat-openbsd-1.203.orig/netcat.c
+++ netcat-openbsd-1.203/netcat.c
@@ -1190,7 +1190,10 @@ remote_connect(const char *host, const c
ahints.ai_flags = AI_PASSIVE;
if ((error = getaddrinfo(sflag, pflag, &ahints, &ares)))
errx(1, "getaddrinfo: %s", gai_strerror(error));
-
+#ifdef IP_BIND_ADDRESS_NO_PORT
+ if(sflag && !pflag)
+ setsockopt(s, SOL_IP, IP_BIND_ADDRESS_NO_PORT, &on, sizeof(on));
+#endif
if (bind(s, (struct sockaddr *)ares->ai_addr,
ares->ai_addrlen) < 0)
err(1, "bind failed");