]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
ping: fix parsing of options including '4' and '6'
authorAlan Somers <asomers@FreeBSD.org>
Wed, 6 Oct 2021 22:54:59 +0000 (16:54 -0600)
committerEd Maste <emaste@FreeBSD.org>
Mon, 13 Dec 2021 01:27:12 +0000 (20:27 -0500)
commitc775b6ebabb3431cce9233bc6cbb66127cbb5ea0
treeb2ab718327bc39cf2f0f9ef309f9f3ef57645a6d
parent4bad5bb129b8f261d84a1d472c8a94384ea19ad4
ping: fix parsing of options including '4' and '6'

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

(cherry picked from commit 9ce201f2ee3ca340032d9cc71d91a36b3b45a4c3)
sbin/ping/main.c
sbin/ping/main.h
sbin/ping/ping.c
sbin/ping/ping6.c
sbin/ping/tests/ping_test.sh