From 016493ed595ae5716f5d1878e13efc99b960dd58 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 18 Aug 2016 11:15:59 -0700 Subject: Extend fuzzers (correctly) to deal with permissive/strict encoding --- test/core/support/percent_decode_fuzzer.c | 7 +++++-- test/core/support/percent_encode_fuzzer.c | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'test/core/support') diff --git a/test/core/support/percent_decode_fuzzer.c b/test/core/support/percent_decode_fuzzer.c index d8d56b831d..329d837d33 100644 --- a/test/core/support/percent_decode_fuzzer.c +++ b/test/core/support/percent_decode_fuzzer.c @@ -49,12 +49,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_memory_counters_init(); gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size); gpr_slice output; - if (gpr_percent_decode_slice(input, false, &output)) { + if (gpr_strict_percent_decode_slice( + input, gpr_url_percent_encoding_unreserved_bytes, &output)) { gpr_slice_unref(output); } - if (gpr_percent_decode_slice(input, true, &output)) { + if (gpr_percent_decode_slice( + input, gpr_compatible_percent_encoding_unreserved_bytes, &output)) { gpr_slice_unref(output); } + gpr_slice_unref(gpr_permissive_percent_decode_slice(input)); gpr_slice_unref(input); counters = grpc_memory_counters_snapshot(); grpc_memory_counters_destroy(); diff --git a/test/core/support/percent_encode_fuzzer.c b/test/core/support/percent_encode_fuzzer.c index 1c65e72cbb..c9548232b5 100644 --- a/test/core/support/percent_encode_fuzzer.c +++ b/test/core/support/percent_encode_fuzzer.c @@ -51,12 +51,16 @@ static void test(const uint8_t *data, size_t size, const uint8_t *dict) { gpr_slice output = gpr_percent_encode_slice(input, dict); gpr_slice decoded_output; // encoder must always produce decodable output - GPR_ASSERT(gpr_percent_decode_slice(output, false, &decoded_output)); + GPR_ASSERT(gpr_strict_percent_decode_slice(output, dict, &decoded_output)); + gpr_slice permissive_decoded_output = + gpr_permissive_percent_decode_slice(output); // and decoded output must always match the input GPR_ASSERT(gpr_slice_cmp(input, decoded_output) == 0); + GPR_ASSERT(gpr_slice_cmp(input, permissive_decoded_output) == 0); gpr_slice_unref(input); gpr_slice_unref(output); gpr_slice_unref(decoded_output); + gpr_slice_unref(permissive_decoded_output); counters = grpc_memory_counters_snapshot(); grpc_memory_counters_destroy(); GPR_ASSERT(counters.total_size_relative == 0); -- cgit v1.2.3