Context: C and C++ locale assumptions in bitcoind and bitcoin-qt
Add fuzzing harness for locale independence testing of functions in strencodings.h
and tinyformat.h
.
Test this PR using:
0$ make distclean
1$ ./autogen.sh
2$ CC=clang CXX=clang++ ./configure --enable-fuzz \
3 --with-sanitizers=address,fuzzer,undefined
4$ make
5$ src/test/fuzz/locale
6…
The tested functions (ParseInt32(…)
, ParseInt64(…)
, atoi(const std::string&)
, atoi64(const std::string& str)
, i64tostr(const char*)
, itostr(…)
, strprintf(…)
) all call locale dependent functions (such as strtol(…)
, strtoll(…)
, atoi(const char*)
, etc.) but are assumed to do so in a way that the tested functions return same results regardless of the chosen C locale (setlocale
).
This fuzzer aims to test that those assumptions hold up also in practice now and over time.