scuffed-code/icu4c/source/test/fuzzer/fuzzer_utils.h
Norbert Runge 219730e167 ICU-20217 Interprets fuzzer data as UCHar* instead of UTF-8. The conversion
from assumed UTF-8 resulted in an extremely large percentage of Unicode
replacement characters in the data passed to the API under test.

ICU-20217 Uses fuzzer generated bytes to make random selection of locales, converters,
etc., replacing the random number generator. This way the fuzzer can control
the selections.

ICU-20217 Minor follow-ups from code review.
Removes fuzzer target break_iterator_utf32_fuzzer which does not perform
anything useful what the regular break iterator fuzzer target already performs.

ICU-20217 Fixes for-loop body.

ICU-20217 Uses am allocated buffer to pass head-truncated fuzzer data to the
API under test. The fuzzer may otherwise not detect buffer underflow.
by

ICU-20217 Typing fix.

ICU-20217 Fixing typing.

ICU-20217 Improve fuzzer targets, move truncated fuzzer data into a
new buffer to prevent that buffer underflow goes undetected.

ICU-20217 Fixes buffer management of fuzzer-provided data.

ICU-20217 Factor in PR review comments.
2019-02-20 15:22:26 -08:00

25 lines
549 B
C

// © 2019 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef FUZZER_UTILS_H_
#define FUZZER_UTILS_H_
#include <assert.h>
#include "unicode/locid.h"
struct IcuEnvironment {
IcuEnvironment() {
// nothing to initialize yet;
}
};
const icu::Locale& GetRandomLocale(uint16_t rnd) {
int32_t num_locales = 0;
const icu::Locale* locales = icu::Locale::getAvailableLocales(num_locales);
assert(num_locales > 0);
return locales[rnd % num_locales];
}
#endif // FUZZER_UTILS_H_