Commit Graph

155 Commits

Author SHA1 Message Date
maya ff0b390a62 un-ifdef sgi. NFC 2017-10-02 10:08:11 +00:00
ryo 2f4136203c Fix cksum calculation for clearing the cached route.
In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.
2017-03-17 06:52:59 +00:00
joerg 2c0cac8e7f Use an explicitly aligned buffer for ip. 2017-01-11 12:13:52 +00:00
dholland 9275630b0c PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.
Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.
2016-12-18 01:19:34 +00:00
dholland e0d8c787c6 PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.
Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.
2016-12-18 00:21:33 +00:00
joerg 7ee1d0f8e6 Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.
2016-10-07 22:31:05 +00:00
dholland fc8d0c1c35 Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.
2016-07-31 18:14:36 +00:00
dholland 52b3d9565c Don't call variables that are used "dummy". 2016-07-31 17:59:08 +00:00
christos b5ac626c87 Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.
2014-11-29 14:48:42 +00:00
christos 0c4052c0de PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?
2014-11-27 19:43:58 +00:00
christos f55ff5e8dd vax specific gcc 4.8.1 hacks 2013-11-09 21:39:27 +00:00
christos 86785464fe avoid bogus uninitialized gcc warning 2013-10-19 01:08:25 +00:00
yamt 4398e962ce more precision for F_TIMING64 2013-03-06 11:33:08 +00:00
christos ed79344487 deduct phdrlen after computing max size. 2012-12-30 03:19:24 +00:00
christos 0ec9e614e3 1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
   with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
   ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
   the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
   a newline before printing the data bytes, and it would append to the previous
   error message.
2012-12-30 02:41:11 +00:00
msaitoh c29bab8ba9 Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR. 2012-09-18 04:07:44 +00:00
drochner 8fd6dadaf8 include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))
2012-01-04 16:09:40 +00:00
christos bdfab20ffb print summary stats. 2011-09-11 17:18:52 +00:00
wiz 72a60d8cd5 Another option order fix. 2011-09-10 20:47:33 +00:00
wiz 51f435b8eb Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.
2011-09-10 20:46:43 +00:00
christos e8ad09e0b7 PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.
2011-09-10 20:04:28 +00:00
joerg c6d7b0bb59 static + __dead 2011-08-27 18:37:41 +00:00
christos 7b373c7105 handle the first loop where time == 0. 2011-08-21 06:39:09 +00:00
christos 6ffa97db52 we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.
2011-08-20 14:38:09 +00:00
christos 3ca3bc9b9b PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@
2011-08-19 08:35:40 +00:00
joerg 90aa08ed31 Don't use array access to compute addresses that are definitely beyond
the static array boundaries.
2011-08-09 12:55:18 +00:00
pooka 3e81f0bf9e Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).
2011-03-11 09:59:56 +00:00
pooka e8de1d91d0 be a happy crunch build 2010-12-13 19:19:10 +00:00
pooka f9740ada7f RUMP_ACTION -> RUMPPRG 2010-12-13 17:42:17 +00:00
pooka afd4d3a773 add compile-conditional rumpclient support 2010-11-11 22:56:38 +00:00
christos 4d3e7c5df2 remove ancient ifdefs (Aleksej Saushev) 2009-11-02 00:47:09 +00:00
lukem cefb0777de fix sign-compare issues 2009-04-11 06:48:36 +00:00
christos 2037025cb5 PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?
2009-03-31 19:51:11 +00:00
seanb fb884caea6 Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459
2008-01-08 20:03:09 +00:00
tls 4147a3c54a Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry.  RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros.  Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default.  Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
2007-05-28 12:06:17 +00:00
hubertf df06563bc3 Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>
2007-01-17 21:59:49 +00:00
elad 38e12255a4 Change error message to say "setuid", forgotten in previous commit.
Pointed out by Ray Lai, thanks!
2006-09-28 16:01:16 +00:00
elad d13f82cf17 On 2nd thought, setuid() is better here. 2006-09-24 11:17:09 +00:00
elad 545c393d67 PR/28741: Michael Santos: ping does [not] drop root privileges
Moved socket calls way up, and called seteuid(getuid()).
2006-09-24 11:05:09 +00:00
yamt ff6f0069a4 prtsig: remove a mysterious abort(). 2006-07-14 05:43:49 +00:00
christos 0ca3098868 Use SA_NOKERNINFO instead of playing with the tty. 2006-06-03 18:19:55 +00:00
christos 53516f73e1 Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.
2006-06-01 18:04:08 +00:00
christos 8d1784140b PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.
2006-06-01 15:59:31 +00:00
mrg 0c37c63edc change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.
2006-05-09 20:18:05 +00:00
pavel d8e5c31820 Clarify and correct the description of the -R (Record Route) flag.
Reviewed by jnemeth, whith help from him.
2006-03-21 22:54:46 +00:00
pavel c38d26c2d6 Bump date, requested by wiz. 2006-03-21 09:54:12 +00:00
pavel 104eb3fa9f -I does work for unicast pings too (it sets the source address).
With some language help from dsl.
Reviewed by jnemeth.
2006-03-21 09:15:53 +00:00
cjep 721eb939af add -h option in synopsis. Fixes PR#25863 from Kouichirou Hiratsuka. 2004-06-08 08:05:30 +00:00
kleink faed9caa49 There's no point in bringing PRNG output to network byteorder prior to
transmission.
2004-05-13 20:27:38 +00:00
itojun 56ae6a5d4c do not disclose endian. henning@openbsd 2004-04-22 01:39:20 +00:00