diff options
author | Craig Tiller <ctiller@google.com> | 2016-08-18 11:15:59 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-08-18 11:15:59 -0700 |
commit | 016493ed595ae5716f5d1878e13efc99b960dd58 (patch) | |
tree | f3ca1d1c18ccc91125d3f0acefa452a736c3af6a /test/core/support | |
parent | 1c7a84202f954e9d4fe328a5fd4eaf8439d894ef (diff) |
Extend fuzzers (correctly) to deal with permissive/strict encoding
Diffstat (limited to 'test/core/support')
-rw-r--r-- | test/core/support/percent_decode_fuzzer.c | 7 | ||||
-rw-r--r-- | test/core/support/percent_encode_fuzzer.c | 6 |
2 files changed, 10 insertions, 3 deletions
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); |