Add a fuzzing harness for CScriptNum::serialize
, core_write.cpp:ValueFromAmount
and util/moneystr.cpp:FormatMoney
.
Those functions manually compute absolute values of int64_t
numbers which can lead to undefined behavior, see : #18413 #18046
You can trigger this new harness with the following input :
0$ echo -n "-9223372036854775808" > crash-abs-value
1$ ./src/test/fuzz/abs_ub crash-abs-value
Note that BitcoinUnits::format
also does the same (but requires QT headers to compile so I’m not sure we can add it to the fuzzer).