On Fri, Oct 18, 2024 at 02:15:43PM -0700, Gleb Smirnoff wrote: T> To achieve what you want, you first need to fully revert your patch, and then T> apply the attached patch. It will consistently disable all the size checks T> that _our_ ping has, instead of incorrectly and blindly applying a diff from T> DragonflyBSD. T> T> HOWEVER, PLEASE DO NOT COMMIT the attached patch!
Sorry, forgot the attach in the previous email. -- Gleb Smirnoff
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index d9d544bc75c8..817889eaf599 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -320,11 +320,6 @@ ping(int argc, char *const *argv) optarg); } sweepmax = (int)ltmp; - if (uid != 0 && sweepmax > DEFDATALEN) { - errc(EX_NOPERM, EPERM, - "packet size too large: %d > %u", - sweepmax, DEFDATALEN); - } options |= F_SWEEP; break; case 'g': /* Minimum packet size for ping sweep */ @@ -334,11 +329,6 @@ ping(int argc, char *const *argv) optarg); } sweepmin = (int)ltmp; - if (uid != 0 && sweepmin > DEFDATALEN) { - errc(EX_NOPERM, EPERM, - "packet size too large: %d > %u", - sweepmin, DEFDATALEN); - } options |= F_SWEEP; break; case 'H': @@ -351,11 +341,6 @@ ping(int argc, char *const *argv) optarg); } sweepincr = (int)ltmp; - if (uid != 0 && sweepincr > DEFDATALEN) { - errc(EX_NOPERM, EPERM, - "packet size too large: %d > %u", - sweepincr, DEFDATALEN); - } options |= F_SWEEP; break; case 'I': /* multicast interface */ @@ -458,12 +443,6 @@ ping(int argc, char *const *argv) errx(EX_USAGE, "invalid packet size: `%s'", optarg); datalen = (int)ltmp; - if (uid != 0 && datalen > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, - "packet size too large: %d > %u", - datalen, DEFDATALEN); - } break; case 'T': /* multicast TTL */ ltmp = strtonum(optarg, 0, MAXTTL, &errstr); @@ -811,9 +790,8 @@ ping(int argc, char *const *argv) cap_rights_init(&rights, CAP_RECV, CAP_EVENT); if (caph_rights_limit(srecv, &rights) < 0) err(1, "cap_rights_limit srecv setsockopt"); - if (uid == 0) - (void)setsockopt(ssend, SOL_SOCKET, SO_SNDBUF, (char *)&hold, - sizeof(hold)); + (void)setsockopt(ssend, SOL_SOCKET, SO_SNDBUF, (char *)&hold, + sizeof(hold)); /* CAP_SETSOCKOPT removed */ cap_rights_init(&rights, CAP_SEND); if (caph_rights_limit(ssend, &rights) < 0)