From 70f98cb218695f16060e5073b8796da6258c5d0e Mon Sep 17 00:00:00 2001 From: Philip Top Date: Tue, 15 Apr 2025 18:44:49 -0700 Subject: [PATCH] fuzzer failure `--sub1.-` interpreting as a short option (#1148) and getting into odd situations --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/CLI/impl/App_inl.hpp | 3 ++- tests/FuzzFailTest.cpp | 2 +- tests/fuzzFail/parse_fail_check3 | Bin 0 -> 24 bytes 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tests/fuzzFail/parse_fail_check3 diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 2e17cb89..fdeab4e0 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -1974,7 +1974,8 @@ App::_parse_arg(std::vector &args, detail::Classifier current_type, } std::string dummy1, dummy2; bool val = false; - if(current_type == detail::Classifier::SHORT || detail::split_long(args.back(), dummy1, dummy2)) { + if((current_type == detail::Classifier::SHORT && detail::valid_first_char(args.back()[1])) || + detail::split_long(args.back(), dummy1, dummy2)) { val = sub->_parse_arg(args, current_type, true); } diff --git a/tests/FuzzFailTest.cpp b/tests/FuzzFailTest.cpp index 683214a9..09ed65d9 100644 --- a/tests/FuzzFailTest.cpp +++ b/tests/FuzzFailTest.cpp @@ -341,7 +341,7 @@ TEST_CASE("app_roundtrip_parse_normal_fail") { // like HorribleErrors CLI::FuzzApp fuzzdata; auto app = fuzzdata.generateApp(); - int index = GENERATE(range(1, 3)); + int index = GENERATE(range(1, 4)); std::string optionString, flagString; auto parseData = loadFailureFile("parse_fail_check", index); std::size_t pstring_start{0}; diff --git a/tests/fuzzFail/parse_fail_check3 b/tests/fuzzFail/parse_fail_check3 new file mode 100644 index 0000000000000000000000000000000000000000..9640122e628598eedbff0edad795871987a4f775 GIT binary patch literal 24 ecmdO8;L_DCE=@Aj(*-ihe7SVFHkPGabOr!H;RbI2 literal 0 HcmV?d00001