Skip to content

Commit

Permalink
Reapply "sbin/ping: allow normal users to specify larger packets"
Browse files Browse the repository at this point in the history
The ping tests were originally broken by an unrelated isue that
is now fixed ( 2926c25 ).

THanks to kp@ for fixing the test and Jose Luis Duran for pinting it out.

This reverts commit 7bc0cb9.
  • Loading branch information
pgiffuni committed Oct 16, 2024
1 parent 60516a5 commit b88df1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions sbin/ping/ping.8
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 15, 2023
.Dd October 15, 2024
.Dt PING 8
.Os
.Sh NAME
Expand Down Expand Up @@ -312,7 +312,6 @@ with the 8 bytes of
ICMP
header data.
.Pp
For IPv4, only the super-user may specify values more than default.
This option cannot be used with ping sweeps.
.Pp
For IPv6, you may need to specify
Expand Down
11 changes: 5 additions & 6 deletions sbin/ping/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
#define DEFDATALEN 56 /* default data length */
#define FLOOD_BACKOFF 20000 /* usecs to back off if F_FLOOD mode */
/* runs out of buffer space */
#define MAXIPLEN (sizeof(struct ip) + MAX_IPOPTLEN)
#define MAXICMPLEN (ICMP_ADVLENMIN + MAX_IPOPTLEN)
#define MAXIPLEN ((int)sizeof(struct ip) + MAX_IPOPTLEN)
#define MAXPAYLOAD (IP_MAXPACKET - MAXIPLEN - ICMP_MINLEN)
#define MAXWAIT 10000 /* max ms to wait for response */
#define MAXALARM (60 * 60) /* max seconds for alarm timeout */
#define MAXTOS 255
Expand Down Expand Up @@ -458,11 +458,10 @@ 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,
if (datalen > MAXPAYLOAD) {
errx(EX_USAGE,
"packet size too large: %d > %u",
datalen, DEFDATALEN);
datalen, MAXPAYLOAD);
}
break;
case 'T': /* multicast TTL */
Expand Down

0 comments on commit b88df1e

Please sign in to comment.