From nobody Wed Aug 25 20:46:59 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 025491781B5B for ; Wed, 25 Aug 2021 20:46:59 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvyhL6b27z4V3y for ; Wed, 25 Aug 2021 20:46:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C01AB22FB9 for ; Wed, 25 Aug 2021 20:46:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 17PKkwUC019414 for ; Wed, 25 Aug 2021 20:46:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 17PKkwBH019413 for bugs@FreeBSD.org; Wed, 25 Aug 2021 20:46:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 258048] 'ping' option parsing broken after merging in 'ping6' code. Date: Wed, 25 Aug 2021 20:46:59 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: ghuckriede@blackberry.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N 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.=