aboutsummaryrefslogtreecommitdiff
path: root/sbin/ping/ping.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-9/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* sbin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* ping: pr_iph() improvementsJose Luis Duran2023-10-111-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very early on, the Src/Dst IP addresses were printed in hex notation (%08x), which will always be 8-characters wide. It was later changed to use a dot-decimal notation. Depending on the IP address length, the Src and Dst headers may require a different padding. Use the source and destination IP lengths as padding for the headers. Also, print an Opts (options) header, if there are options present. It has been abbreviated to Opts to match the length of the previous Data header, removed in ef9e6dc7eebe9830511602904d3ef5218d964080. Print the header info such that no trailing spaces are produced. As some git workflows may automatically trim them, and make the tests fail (see 25b86f8559c2e7076daff56933217e95cd4398d4). Before Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2␣ After Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 And with options: Before Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 01... After Vr HL TOS Len ID Flg off TTL Pro cks Src Dst Opts 4 f 00 007c 0001 0 0000 40 01 d868 192.0.2.1 192.0.2.2 01... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39561
* ping: Fix the spacing between the time stamp and cp/dpJose Luis Duran2023-10-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an echo reply packet is received, the data is compared with the sent data. When a wrong byte is detected the command displays a report with the differences. The first row (the first 8-bytes of data after the ICMP header) should include the time stamp (if data is at least 8-bytes), this value is not taken into consideration for the comparison. The remaining rows represent the data (padded pattern) received/sent, with each byte being compared for differences. Print the space before (not after), to add an extra space after cp:/dp: for better readability when the first time stamp octet is not zero-padded, and to remove trailing spaces in the output. Before: cp:99 0 0 c 1 5 c 0␣ ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd␣ ... After: cp: 99 0 0 c 1 5 c 0 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39492
* ping: Unify ping/ping6 statistics sectionJose Luis Duran2023-10-111-138/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a first step towards a unification/simplification of ping/ping6 (internally). The end goal is to produce a standardized user-facing output. Before (ping6): PING6(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2 16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms 16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms --- 2001:db8::2 ping6 statistics --- round-trip min/avg/max/std-dev = 0.068/0.118/0.168/0.050 ms After (ping6): PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2 16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms 16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms --- 2001:db8::2 ping statistics --- round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms This has the nice side-effect of adding units to SIGINFO's statistics, as printing numbers without units may not be of much help. Also mentions the fact that these times are round-trip. Before (ping/ping6 SIGINFO): 2/2 packets received (100.0%) 0.068 min / 0.118 avg / 0.168 max After (ping/ping6 SIGINFO): --- <ipv4/ipv6 address> ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms In the case of a SIGINFO, the output will be printed to stderr, for both ping and ping6. Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39126
* ping: Specify the sigaction(2) nameJose Luis Duran2023-10-111-1/+1
| | | | | | | | | | After a2a008880568eaeb87d8404b39627b83df851f34, specify the signal name. Obtained from: Darwin MFC after: 1 week Reviewed by: asomers Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D38484
* ping: Remove an extra new line characterJose Luis Duran2023-10-111-1/+1
| | | | | | | | | This matches the behavior when an RR truncated route is printed. Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39485
* ping: Avoid reporting NaNsJose Luis Duran2023-10-111-2/+2
| | | | | | | | | | | | | | | | | | | Avoid calculating the square root of negative zero, which can easily happen on certain architectures when calculating the population standard deviation with a sample size of one, e.g., 0.01 - (0.1 * 0.1) = -0.000000. Avoid returning a NaN by capping the minimum possible variance value to zero (positive). In the future, maybe skip reporting statistics at all for a single sample. Reported by: Jenkins Reviewed by: asomers MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D42114
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* ping: Fix an uninitialized variableJose Luis Duran2023-03-241-0/+3
| | | | | | | | | | | | | | | The variable oicmp, which holds the original ("quoted packet") ICMP packet in a structured way, did not have a copy of the original ICMP packet obtained from the raw data. The code was accidentally removed in 20b41303140e. Bring it back. Reported by: Coverity Scan, cy Reviewed by: cy CID: 1506960 (UNINIT) Fixes: 20b41303140eee4dfb896558fb83600c5f013d39 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39233
* ping: Avoid reporting negative time statisticsJose Luis Duran2023-03-191-1/+7
| | | | | | | | | Display a warning when the time goes back. PR: 192417 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38480
* ping: Remove pr_retip()Jose Luis Duran2023-03-191-28/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Ping used to provide some sort of packet sniffing capabilities, this was in an era where hubs were used and tcpdump wasn't invented. pr_iph() is a function that prints the IP header of the packet. pr_retip() is essentially a wrapper function to pr_iph(), that also displays the source and destination ports of a TCP or UDP packet. After ef9e6dc7eebe9830511602904d3ef5218d964080 some of this functionality was almost removed, to only display packets sent by us (26+ years ago). At this point, reaching this code path was only possible by doctoring the original packet. After 46d7b45a267b3d78c5054b210ff7b6c55bfca42b this code path can never be reached. Remove the code. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38475
* ping: Print the IP options of the original packetJose Luis Duran2023-03-191-9/+10
| | | | | | | | | | | | | | | | | | | When an ICMP packet contains an IP packet in its payload, and that original IP packet contains options, these options were not displayed accordingly in pr_iph(). pr_iph() is a function that prints the original "quoted packet" IP header, with only an IP struct as an argument. The IP struct does not contain IP options, and it is not guaranteed that the options will be contiguous in memory to the IP struct after d9cacf605e2ac0f704e1ce76357cbfbe6cb63d52. Pass the raw ICMP data along with the IP struct, in order to print the options, if any. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38469
* ping: Avoid magic numbersJose Luis Duran2023-03-171-3/+3
| | | | | | | | | | | The sizeof(struct ip) is 20. The sizeof(struct in_addr) is 4. No functional change intended. Reviewed by: asomers, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39125
* ping: Remove ifndef icmp_data guardsJose Luis Duran2023-03-141-4/+0
| | | | | | | | | | | | | | Early versions of <netinet/ip_icmp.h> [1] did not have icmp_data defined, but FreeBSD has always had. Remove these guards. NetBSD [2] and OpenBSD [3] have already removed them. [1]: https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/netinet/ip_icmp.h [2]: https://github.com/NetBSD/src/commit/203dfd34867991fd002f747d74a96f26ae80d41c [3]: https://github.com/openbsd/src/commit/d83449c83c03b86e72d642dc92bcea434310435a Reviewed by: markj MFC after: 1 week
* ping: Fix the display of Flags/Fragment OffsetJose Luis Duran2023-03-141-3/+3
| | | | | | | | | | | | | | | | | | | | | In the IP header, Flags + Fragment Offset is a 16-bit field. Use ntohs() instead of ntohl(), otherwise the Flags/Fragment Offset values may not display correctly. Before (DF set) Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 5 00 0054 0001 0 0000 40 01 b6a4 192.0.2.1 192.0.2.2 After (DF set) Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 5 00 0054 0001 2 0000 40 01 b6a4 192.0.2.1 192.0.2.2 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38479
* ping: Fix unsigned integer underflow resuling in a ping -R segfaultCy Schubert2023-02-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ping -R (F_RROUTE) will loop at ping.c:1381 until it segfaults or the unsigned int hlen happens to be less than the size of an IP header: slippy$ ping -R 192.168.0.101 PING 192.168.0.101 (192.168.0.101): 56 data bytes 64 bytes from 192.168.0.101: icmp_seq=0 ttl=63 time=1.081 ms RR: 192.168.0.1 192.168.0.101 192.168.0.101 10.1.1.254 10.1.1.91 unknown option bb unknown option 32 unknown option 6 ... unknown option 96 unknown option 2d Segmentation fault The reason for this is while looping through loose source routing (LSRR) and strict source routing (SSRR), hlen will become smaller than the IP header. It may even become negative. This should terminate the loop. However, when hlen is unsigned, an integer underflow occurs becoming a large number causing the loop to continue virtually forever until hlen is either by chance smaller than the lenghth of an IP header or it segfaults. Reviewed by: asomers Fixes: 46d7b45a267b MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D38744
* ping: Fix handling of IP packet sizesTom Jones2022-11-291-9/+60
| | | | | | | | | | | | | | | | | | | | Ping reads raw IP packets to parse ICMP responses. When reading the IP Header Len (IHL) ping was was taking the value from the provided packet without any validation. This could lead to remotely triggerable stack corruption. Validate the IHL against expected and recieved data sizes when reading from the received packet and when reading any quoted packets from within the ICMP response. Approved by: so Reviewed by: markj, asomers Security: FreeBSD-SA-22:15.ping Security: CVE-2022-23093 Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #77 Differential Revision: https://reviews.freebsd.org/D37195
* ping: Remove a vestigial notdefJose Luis Duran2022-11-031-16/+0
| | | | | | | | | | | | | | | | | It was once a function on 4.3BSD, pr_type() [1], used to convert an ICMP "type" field to a printable string. In 4.4BSD it was superseded by pr_icmph() [2]. NetBSD [3] and OpenBSD [4] have already removed it. [1]: https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/src/etc/ping.c [2]: https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/sbin/ping/ping.c [3]: https://github.com/NetBSD/src/commit/203dfd34867991fd002f747d74a96f26ae80d41c [4]: https://github.com/openbsd/src/commit/9bbbbbb75d24e3d166ddd0cb6cb4417b78561309 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D37247
* ping: split the visual part of -f into a new option -.Piotr Pawel Stefaniak2022-04-181-6/+17
| | | | | | | | | After this, we'll be able to ping a host and not spam the terminal, and no flooding will have to be involved. I've been doing this under Linux as ping -fi1 host. Reviewed by: rpokala, Pau Amma Differential Revision: https://reviews.freebsd.org/D34882
* ping: fix parsing of options including '4' and '6'Alan Somers2021-10-211-9/+1
| | | | | | | | | | | | | | | | | | ping uses a two-pass option parser. The first pass determines whether ipv4 or ipv6 is desired, and the second parses the rest of the options. But the first pass wrongly detects a '4' or '6' in an option's value as a request to use ipv6 or ipv6 respectively, for example in an invocation like "ping -c6 1.2.3.4". Fix this confusion by including all options in the first round of parsing, but ignoring those unrelated to ipv4/ipv6 selection. PR: 258048 Reported by: ghuckriede@blackberry.com Submitted by: ghuckriede@blackberry.com MFC after: 2 weeks Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D32344
* Merge ping6 to pingAlan Somers2020-11-261-24/+7
| | | | | | | | | | | | | There is now a single ping binary, which chooses to use ICMP or ICMPv4 based on the -4 and -6 options, and the format of the address. Submitted by: Ján Sučan <sucanjan@gmail.com> Sponsored by: Google LLC (Google Summer of Code 2019) MFC after: Never Differential Revision: https://reviews.freebsd.org/D21377 Notes: svn path=/head/; revision=368045
* ping(8): Improve parameter validationMark Johnston2020-11-241-52/+58
| | | | | | | | | | | | | - Use strtonum(3) to simplify bounds checking of numeric parameters. - Fix bounds checking when filling out packet data in "sweep" mode. PR: 239974, 239977, 239978 Reported by: Neeraj <neerajpal09@gmail.com> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25622 Notes: svn path=/head/; revision=367988
* Make use of IP_VLAN_PCP setsockopt in ping and ping6.Richard Scheffenegger2020-10-241-5/+17
| | | | | | | | | | | | | In order to validate the proper marking and use of a different ethernet priority class, add the new session-specific PCP feature to the ping/ping6 utilities. Reviewed by: mav, bcr Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D26627 Notes: svn path=/head/; revision=367021
* ping(8): Check for integer truncation when handling the value for -s.Mark Johnston2020-07-111-1/+1
| | | | | | | | | | PR: 239976 Submitted by: Neeraj <neerajpal09@gmail.com> MFC after: 1 week Event: July 2020 Bugathon Notes: svn path=/head/; revision=363102
* ping, ping6: Use setitimer(2) instead of obsolete alarm(3)Alan Somers2019-11-261-1/+9
| | | | | | | | Submitted by: Ján Sučan <sucanjan@gmail.com> Differential Revision: https://reviews.freebsd.org/D22103 Notes: svn path=/head/; revision=355106
* ping: Verify whether a datagram timestamp was actually received.Alan Somers2019-09-111-1/+2
| | | | | | | | | | | | | | | | | | ping(8) uses SO_TIMESTAMP, which attaches a timestamp to each IP datagram at the time it's received by the kernel. Except that occasionally it doesn't. Add a check to see whether such a timestamp was actually set before trying to read it. This fixes segfaults that can happen when the kernel doesn't attach a timestamp. The bug has always existed, but prior to r351461 it manifested as an implausible round-trip-time, not a segfault. Reported by: pho MFC after: 3 days MFC-With: 351461 Notes: svn path=/head/; revision=352229
* ping: fix a string in an error messageAlan Somers2019-09-111-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=352226
* ping: fix unaligned access to ancillary dataAlan Somers2019-08-241-3/+2
| | | | | | | | | | | | | Use CMSG_FIRSTHDR rather than assume that an array is correctly aligned. Fixes warnings on sparc64 and powerpcspe. Submitted by: Ján Sučan <sucanjan@gmail.com> MFH: 2 weeks Sponsored by: Google LLC (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21406 Notes: svn path=/head/; revision=351461
* ping: Fix alignment errorsAlan Somers2019-08-231-98/+104
| | | | | | | | | | | | This fixes -Wcast-align errors when compiled with WARNS=6. Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google LLC (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21327 Notes: svn path=/head/; revision=351440
* ping: By default, don't reverse lookup IP addressesAlan Somers2019-08-221-0/+2
| | | | | | | | | | | | | | | | | ping's default is now not to attempt reverse DNS lookups. The -H flag will enable them. This change is not quite a reversion of r351330. That change made the happy path and error path do reverse lookups consistently; this change changes the default for both paths. Submitted by: Ján Sučan <sucanjan@gmail.com> Discussed with: cem MFC after: 2 weeks MFC-With: 351330 Sponsored by: Google LLC (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21364 Notes: svn path=/head/; revision=351398
* ping: add -H option for enabling reverse DNS lookupAlan Somers2019-08-211-3/+6
| | | | | | | | | | | This is the reverse of the -n flag. Submitted by: Ján Sučan <sucanjan@gmail.com> Sponsored by: Google LLC (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21356 Notes: svn path=/head/; revision=351354
* ping: do reverse DNS lookup of the target addressAlan Somers2019-08-211-2/+1
| | | | | | | | | | | | | | | When printing replies, ping will now attempt a reverse DNS lookup of the target. That can be suppressed by using the "-n" option. Curiously, ping has always done reverse lookups in certain error paths, but never in the success path. Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google LLC (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21351 Notes: svn path=/head/; revision=351330
* Fix uninitialized variable warnings when MK_CASPER=noAlan Somers2019-08-191-3/+6
| | | | | | | | | | Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21322 Notes: svn path=/head/; revision=351226
* ping: fix -Wformat-truncating warning with GCCAlan Somers2019-08-191-1/+1
| | | | | | | | | | | | | | | | | | Increase buffer size for the string representation of n_time ICMP timestamp is a 32-bit number. In pr_ntime(), number of minutes and seconds is always 2 characters wide. Max. number of hours is 4 characters wide. The buffer size should be at least: 4 + 2 + 2 + 1 (':') + 1 (':') + 1 ('\0') = 11 Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21325 Notes: svn path=/head/; revision=351223
* ping: Move in_cksum() to a separate source fileAlan Somers2019-08-171-48/+2
| | | | | | | | | | | | | | This is a preparation step for adding ATF tests of in_cksum(), which has been modified to operate on unaligned data. ping.o cannot be linked to the test executable because both of them contain 'main' symbol. Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21288 Notes: svn path=/head/; revision=351171
* ping: Make in_cksum() operate on u_char bufferAlan Somers2019-08-141-8/+12
| | | | | | | | | | | | | This fixes -Wcast-align errors for in_cksum() calls when compiled with WARNS=6. Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21261 Notes: svn path=/head/; revision=351033
* ping: fix triptime calculation after r350998Alan Somers2019-08-141-3/+9
| | | | | | | | | | | | | | That revision changed the internal clock to the monotonic, but neglected to change the datagram's timestamp source. Reported by: Oliver Hartmann, Michael Butler Reviewed by: Ján Sučan <sucanjan@gmail.com>, allanjude MFC after: 2 weeks MFC-With: r350998 Differential Revision: https://reviews.freebsd.org/D21258 Notes: svn path=/head/; revision=351030
* ping: use the monotonic clock to measure durationsAlan Somers2019-08-131-55/+36
| | | | | | | | | | Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21245 Notes: svn path=/head/; revision=350998
* ping: fix data type of a variable for a packet sequence numberAlan Somers2019-08-131-1/+2
| | | | | | | | | | Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21244 Notes: svn path=/head/; revision=350994
* Use caph_enter_casper() in ping(8).Mark Johnston2018-12-181-1/+1
| | | | | | | | | Reported by: oshogbo MFC with: r341837 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342192
* Use Capsicum helpers in ping(8).Mark Johnston2018-12-121-14/+7
| | | | | | | | | | | | | Also use caph_cache_catpages() to ensure that strerror() works when run with kern.trap_enotcap=1. Reviewed by: oshogbo MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18514 Notes: svn path=/head/; revision=341837
* ping(8): add space after "<=" as per style(9).Eugene Grosbein2018-12-101-1/+1
| | | | | | | | MFC after: 1 week X-MFC-with: r341768 Notes: svn path=/head/; revision=341795
* ping(8): remove needless comparision with LONG_MAXEugene Grosbein2018-12-091-1/+1
| | | | | | | | | after unsigned long ultmp changed to long ltmp in r340245. MFC after: 1 week Notes: svn path=/head/; revision=341768
* libcasper: ange the name of limits in cap_dns so the intentions are obvious.Mariusz Zaborski2018-11-121-3/+3
| | | | | | | | Reported by: pjd MFC after: 3 weeks Notes: svn path=/head/; revision=340363
* ping(8): improve diagnostics in case of wrong arguments.Eugene Grosbein2018-11-081-40/+41
| | | | | | | | | | | | | | | | | | | For example, in case of super-user: $ sudo ping -s -64 127.0.0.1 PING 127.0.0.1 (127.0.0.1): -64 data bytes ping: sendto: Invalid argument For unprivileged user: $ ping -s -64 127.0.0.1 ping: packet size too large: 18446744073709551552 > 56: Operation not permitted Fix this by switching from strtoul() to strtol() for integer arguments and adding explicit checks for negative values. MFC after: 1 month Notes: svn path=/head/; revision=340245
* ping: simplify use of CasperMariusz Zaborski2018-11-041-13/+3
| | | | | | | | | There is no need to check if capdns is NULL. If we will build the system without casper all cap_gethostaddr will be replaced by the standard functions. Notes: svn path=/head/; revision=340143
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* We return a pointer when we are using cap_init() or cap_service_open()Mariusz Zaborski2017-11-121-1/+1
| | | | | | | | | | | | function, so check if cap_chanel_t is NULL is not enough. Casper with a normal libc will still fail in capability mote so let's not enter capability mode without casper support when we need to resolve DNS. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D12823 Notes: svn path=/head/; revision=325736
* Simplify ping sandbox.Mariusz Zaborski2017-10-281-20/+0
| | | | | | | | | | We don't need to check if casper is present, this is done in the library itself. Reviewed by: emaste, cem, ed Differential Revision: https://reviews.freebsd.org/D8754 Notes: svn path=/head/; revision=325064