Date: Wed, 25 Aug 2021 20:46:59 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 258048] 'ping' option parsing broken after merging in 'ping6' code. Message-ID: <bug-258048-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258048 Bug ID: 258048 Summary: 'ping' option parsing broken after merging in 'ping6' code. Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: ghuckriede@blackberry.com Created attachment 227435 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D227435&action= =3Dedit Potential Fix Overview: When ping6 was merged into ping, the option parsing was broken. During the first pass of the options, to determine ipv4 or ipv6, only optio= ns "46" are provided to getopt(). This causes getopt() to match any '4' or '6= ', because it believes these are the only valid options. Below are some examples of how the first pass into getopt() is interpreted: "-c6" will match 'c' as invalid (which is ignored) and '6' as ipv6 (instead= of a count of 6) "-s46" will match 's' as invalid (which is ignored), '4' as ipv4, and '6' as ipv6 (instead of a size of 46). I've provided a diff that moves the option string creation to main.h and us= es that for all getopt() calls. The diff also includes the following additional fixes: - Reorder the PING6ADDOPTS options alphabetically like the PING4ADDOPTS. - Add missing space after the "[-m ttl]" option the in usage() text. - Swap the "aA" with "Aa" in the ping 6 usage() text to match PING6ADDOPTS. - Add some #ifdef IPSEC around some unused declarations. Steps to Reproduce: ping -s46 127.0.0.1 ping -s46 ::1 ping -4 -c6 127.0.0.1 ping -6 -c4 ::1=20=20=20=20=20=20=20 ping -4 -t6 127.0.0.1 ping -6 -t4 ::1=20=20=20=20=20=20=20 ping -6 -t4 ::1 ping -6 -z4 -c1 ::1 ping -s6 -c1 127.0.0.1 ping -s4 -c1 ::1 Actual Results: All the "valid" command above return the following errors. "ping: -4 and -6 cannot be used simultaneously" OR "ping: IPv6 requested but IPv4 target address provided" Expected Results: ping should not interpret '4' and '6' in the values of other options as "options". Build Date & Hardware:=20 git HEAD @ 9f7a81b133c715f649136dcd0ad004e4180c56c9 Additional Information: none --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-258048-227>