提交 dc04261a 编写于 作者: G Garret Rieger

[subset] Update the subset fuzzer to determine which options to use based on...

[subset] Update the subset fuzzer to determine which options to use based on data in the fuzzing test case.
Add support for toggling retain_gids.
上级 d983c529
......@@ -11,11 +11,13 @@ trySubset (hb_face_t *face,
const hb_codepoint_t text[],
int text_length,
bool drop_hints,
bool drop_layout)
bool drop_layout,
bool retain_gids)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
hb_subset_input_set_drop_hints (input, drop_hints);
hb_subset_input_set_drop_layout (input, drop_layout);
hb_subset_input_set_retain_gids (input, retain_gids);
hb_set_t *codepoints = hb_subset_input_unicode_set (input);
for (int i = 0; i < text_length; i++)
......@@ -32,16 +34,14 @@ trySubset (hb_face_t *face,
static void
trySubset (hb_face_t *face,
const hb_codepoint_t text[],
int text_length)
int text_length,
const uint8_t flags[1])
{
for (unsigned int drop_hints = 0; drop_hints < 2; drop_hints++)
{
for (unsigned int drop_layout = 0; drop_layout < 2; drop_layout++)
{
trySubset (face, text, text_length,
(bool) drop_hints, (bool) drop_layout);
}
}
bool drop_hints = flags[0] & (1 << 0);
bool drop_layout = flags[0] & (1 << 1);
bool retain_gids = flags[0] & (1 << 2);
trySubset (face, text, text_length,
drop_hints, drop_layout, retain_gids);
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
......@@ -55,21 +55,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
hb_face_collect_unicodes (face, output);
hb_set_destroy (output);
uint8_t flags[1] = {0};
const hb_codepoint_t text[] =
{
'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2',
'3', '@', '_', '%', '&', ')', '*', '$', '!'
};
trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t));
trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t), flags);
hb_codepoint_t text_from_data[16];
if (size > sizeof(text_from_data)) {
if (size > sizeof(text_from_data) + sizeof(flags)) {
memcpy (text_from_data,
data + size - sizeof(text_from_data),
sizeof(text_from_data));
memcpy (flags,
data + size - sizeof(text_from_data) - sizeof(flags),
sizeof(flags));
unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t);
trySubset (face, text_from_data, text_size);
trySubset (face, text_from_data, text_size, flags);
}
hb_face_destroy (face);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册