From 2cb6e4f5215cada460aca50346478725bf754231 Mon Sep 17 00:00:00 2001 From: Kartik Naik Date: Sun, 26 Jul 2026 18:47:36 +0530 Subject: error out when nc minttl is unsupported in set_common_sockopts --- patches/netcat.c.patch | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch index 0383034..680f02b 100644 --- a/patches/netcat.c.patch +++ b/patches/netcat.c.patch @@ -131,7 +131,7 @@ } if (Iflag) { if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, -@@ -1612,13 +1641,17 @@ set_common_sockopts(int s, int af) +@@ -1612,13 +1641,27 @@ set_common_sockopts(int s, int af) } if (minttl != -1) { @@ -139,6 +139,11 @@ if (af == AF_INET && setsockopt(s, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl))) err(1, "set IP min TTL"); ++#else ++ if (af == AF_INET) { ++ errno = ENOPROTOOPT; ++ err(1, "set IP min TTL not supported"); ++ } +#endif - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, @@ -146,11 +151,16 @@ + if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) err(1, "set IPv6 min hop count"); ++#else ++ if (af == AF_INET6) { ++ errno = ENOPROTOOPT; ++ err(1, "set IPv6 min hop count not supported"); ++ } +#endif } } -@@ -1849,15 +1882,19 @@ help(void) +@@ -1849,15 +1892,19 @@ help(void) \t-P proxyuser\tUsername for proxy authentication\n\ \t-p port\t Specify local port for remote connects\n\ \t-R CAfile CA bundle\n\ -- cgit v1.2.3-55-g6feb From 77bf7f28ec393eae42719aea28b9191fa4c0d7cb Mon Sep 17 00:00:00 2001 From: Kartik Naik Date: Wed, 29 Jul 2026 16:16:59 +0530 Subject: use errx instead of setting errno for unsupported minttl --- patches/netcat.c.patch | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch index 680f02b..216debc 100644 --- a/patches/netcat.c.patch +++ b/patches/netcat.c.patch @@ -131,7 +131,7 @@ } if (Iflag) { if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, -@@ -1612,13 +1641,27 @@ set_common_sockopts(int s, int af) +@@ -1612,13 +1641,23 @@ set_common_sockopts(int s, int af) } if (minttl != -1) { @@ -140,10 +140,8 @@ IP_MINTTL, &minttl, sizeof(minttl))) err(1, "set IP min TTL"); +#else -+ if (af == AF_INET) { -+ errno = ENOPROTOOPT; -+ err(1, "set IP min TTL not supported"); -+ } ++ if (af == AF_INET) ++ errx(1, "set IP min TTL not supported"); +#endif - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, @@ -152,15 +150,13 @@ IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) err(1, "set IPv6 min hop count"); +#else -+ if (af == AF_INET6) { -+ errno = ENOPROTOOPT; -+ err(1, "set IPv6 min hop count not supported"); -+ } ++ if (af == AF_INET6) ++ errx(1, "set IPv6 min hop count not supported"); +#endif } } -@@ -1849,15 +1892,19 @@ help(void) +@@ -1849,15 +1888,19 @@ help(void) \t-P proxyuser\tUsername for proxy authentication\n\ \t-p port\t Specify local port for remote connects\n\ \t-R CAfile CA bundle\n\ -- cgit v1.2.3-55-g6feb