3 minor findings · 2 suggestions
Earlier concerns neither republished nor resolved: 3 minor findings · 5 suggestions. See the Run archive for their assessments.
Findings
[minor] · System fuzz target can throw uncaught type errors
Reachable harness inputs can make the final getters throw uncaught std::logic_error, causing a fuzz crash in the harness rather than product code.
Location: src/test/fuzz/system.cpp:40 (head).
Details and suggested fix
Two harness sequences can reach uncaught type errors. AddArg can register -chain with flags such as ALLOW_INT, ALLOW_BOOL, or ALLOW_STRING | ALLOW_LIST; the final GetChainTypeString() call then reaches GetArg("-chain") and throws from CheckArgFlags(). The harness catches only std::runtime_error around that call. Alternatively, ClearArgs() removes the initial -help-debug registration, after which AddArg can register it with ALLOW_INT; the unguarded GetHelpMessage() call then throws from GetBoolArg("-help-debug", false). Wrap both calls in the message-filtered logic_error handler already used for direct getters. Update the comment near the initial registration to name GetHelpMessage(): HelpRequested() only calls IsArgSet(), which does not check flags.
[minor] · Soft-setting false changes untyped settings into negation markers
For existing ALLOW_ANY options, soft-setting false changes the values returned by GetSetting(), IsArgNegated(), and GetArgs(), though the commit message says untyped behavior is unchanged.
Location: src/common/args.cpp:717 (head).
Details and suggested fix
SoftSetBoolArg(name, false) used to store the string "0"; it now stores JSON false for every argument, including untyped ones. SettingsSpan treats false as a negation marker. For an ALLOW_ANY option, GetSetting() therefore returns false instead of "0", IsArgNegated() returns true even though its documentation says it reports a -nofoo argument, and GetSettingsList() and GetArgs() return an empty list instead of ["0"]. GetBoolArg(), GetIntArg(), and GetArg() still return false, 0, and "0". Startup code soft-sets -dnsseed, -listen, -natpmp, -discover, and other options to false. No current code was found that reads those options with IsArgNegated(), GetArgs(), or GetSettingsList(), so production impact is unconfirmed. Use the result of CheckArgFlags() to store a native bool only for typed ALLOW_BOOL arguments, and retain "1" or "0" for untyped arguments.
[minor] · Dashless setting names bypass type checks
Because getters accept both foo and -foo but flag lookup only finds -foo, a typed setting can return different values depending on how its name is spelled.
Location: src/common/args.cpp:389 (head).
Details and suggested fix
CheckArgFlags() looks up flags using the name exactly as passed, while GetArgFlags_() matches registered names such as -foo. GetSetting() strips a leading dash with SettingName(), so getters also accept foo. A dashless call on a typed setting finds no flags, treats the setting as untyped, and applies legacy coercions. For example, with an ALLOW_BOOL setting parsed from -foo=, GetBoolArg("-foo", false) returns false, but GetBoolArg("foo", false) returns true through InterpretBool(""). A mismatched getter such as GetIntArg("foo") on an ALLOW_BOOL setting also skips the intended logic_error. Normalize the name to '-' + SettingName(name) before looking up flags, and cover both spellings in the typed tests. Dashless getter calls exist in getarg_tests, and no production setting uses type flags yet, so production impact is unconfirmed.
Optional improvements
[suggestion] · Rejected AddArg registrations leave state behind
Flag combinations are checked after insertion, so catching a logic_error leaves rejected flags registered and a corrected retry hits the duplicate-registration assertion.
Location: src/common/args.cpp:780 (head).
Details and suggested fix
AddArg() inserts the argument into m_available_args, and into m_network_only_args for NETWORK_ONLY, before checking the flag combinations. If a check throws, neither change is undone. GetArgFlags() then returns the rejected flags, and retrying with corrected flags trips the duplicate-registration Assert. Move the combination checks before insertion so a failed call leaves no state behind. No current caller catches and retries, and util_CheckBadFlagCombinations uses a fresh name for each case.
[suggestion] · Example narrows a validated int64_t without checking its upper bound
The documented reference example accepts -bytespersigop=4294967296 on a system with 32-bit int and stores 0, bypassing the check intended to reject it.
Location: src/test/argsman_tests.cpp:112 (head).
Details and suggested fix
ReadOptions() is the usage example linked from the new args.h documentation. It checks the int64_t returned by GetIntArg("-bytespersigop") only for values below 1, then assigns it to int bytes_per_sigop. With a 32-bit int, -bytespersigop=4294967296 passes parsing and the check, then becomes 0. Reject values above std::numeric_limits<int>::max() before the assignment, and add a boundary case to ExampleOptions so the example demonstrates complete range validation.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Clarify duplicate checking across included config files
- [minor]: GetArgs rejects integer list settings
- [minor]: SoftSetArg can set an unreadable typed value
- [suggestion]: Clarify whether type flags validate settings.json
- [minor]:
ALLOW_BOOL | ALLOW_LISTloses explicit false values and earlier entries (earlier report) - [suggestion]: Narrow typed integer getters throw a generic out-of-range error (earlier report)
- [suggestion]: Typed
GetArgtreats JSONtrueas unset despite the documented bool-to-string widening (earlier report) - [suggestion]: Parsing-only test constructs an unused 100-block chain (earlier report)