File enable-udp-ip_recverr.patch of Package netcat-openbsd

Index: netcat-openbsd-1.229/netcat.c
===================================================================
--- netcat-openbsd-1.229.orig/netcat.c	2025-06-04 07:36:53.985608901 +0000
+++ netcat-openbsd-1.229/netcat.c	2025-06-04 07:37:13.091297946 +0000
@@ -1990,6 +1990,21 @@ connection_info(const char *host, const
 	fprintf(stderr, " %s port [%s/%s] succeeded!\n", port, proto, service);
 }
 
+static int
+enable_icmp_errors (int family, int fd)
+{
+  int one = 1;
+  switch (family)
+    {
+    case AF_INET:
+      return setsockopt (fd, SOL_IP, IP_RECVERR, &one, sizeof (one));
+    case AF_INET6:
+      return setsockopt (fd, SOL_IPV6, IPV6_RECVERR, &one, sizeof (one));
+    default:
+      return -1;
+    }
+}
+
 void
 set_common_sockopts(int s, const struct sockaddr* sa)
 {
@@ -2084,6 +2099,8 @@ set_common_sockopts(int s, const struct
 			errx(1, "can't set IPv6 min hop count (unavailable)");
 #endif
 	}
+	if(uflag)
+		enable_icmp_errors(af,s);
 }
 
 int
openSUSE Build Service is sponsored by