Isolated harness for SanitizeString(), need a little edit to fit the fuzz coding pattern, I believe the extern "C" int LLVMFuzzerTestOneInput() would be translated to:
FUZZ_TARGET(sanitizestring)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
[...]
}
I am not that familiar with the whole fuzz codebase pattern yet to follow with the proper syntax.
The recommended fix from @laawnj is to " make the second argument of SanitizeString an "SafeChars" enum. This prevents a unhandled value from ever being passed in."
[1] and [2] point to so some references where the second argument is not passed as an enum but there is more cases under the same conditions so I recommend to do some x-reference to double check them.