Page MenuHomeFreeBSD

ping: fix parsing of options including '4' and '6'
ClosedPublic

Authored by asomers on Oct 6 2021, 10:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 12:25 PM
Unknown Object (File)
Jan 15 2024, 11:24 PM
Unknown Object (File)
Dec 23 2023, 12:07 AM
Unknown Object (File)
Dec 12 2023, 10:36 PM
Unknown Object (File)
Dec 8 2023, 7:34 PM
Unknown Object (File)
Dec 2 2023, 6:39 AM
Unknown Object (File)
Oct 23 2023, 7:52 AM
Unknown Object (File)
Sep 22 2023, 10:41 AM
Subscribers

Details

Summary

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

Test Plan

tests added

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 41993
Build 38881: arc lint + arc unit

Event Timeline

should we add a test for exit:1 with -46 specified?

sbin/ping/tests/ping_test.sh
31

I wonder if we could cache this?

should we add a test for exit:1 with -46 specified?

Yeah, sure.

sbin/ping/tests/ping_test.sh
31

No, because every ATF test case runs in its own process. And it only takes about 5ms on my system, anyway.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 21 2021, 12:06 AM
This revision was automatically updated to reflect the committed changes.