From a94440b1e42080777249b879ce90747af2c9be7f Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Tue, 30 Jul 2024 03:58:33 -0700 Subject: [PATCH] adjust test_idna to avoid double allocations Signed-off-by: David Korczynski --- .clusterfuzzlite/libuv_fuzzer.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.clusterfuzzlite/libuv_fuzzer.c b/.clusterfuzzlite/libuv_fuzzer.c index 8213e1671..695bd7af8 100644 --- a/.clusterfuzzlite/libuv_fuzzer.c +++ b/.clusterfuzzlite/libuv_fuzzer.c @@ -31,20 +31,11 @@ static uv_loop_t* loop; static void dummy_cb(uv_fs_t* req) { (void)req; } -void test_idna(const uint8_t* data, size_t size) { - char* new_str = malloc(size + 1); - if (new_str == NULL) - return; - - memcpy(new_str, data, size); - new_str[size] = '\0'; - +void test_idna(char *payload, size_t size) { char de[256]; - uv__idna_toascii(new_str, new_str + size, de, de + 256); + uv__idna_toascii(payload, payload + size, de, de + 256); - uv_wtf8_length_as_utf16(new_str); - - free(new_str); + uv_wtf8_length_as_utf16(payload); } void test_file_ops_1(const uint8_t* data, size_t size) { @@ -144,7 +135,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } else if (decider == 4) { test_file_ops_2(data, size); } else if (decider == 5) { - test_idna(data, size); + test_idna(new_str, size); } else { uv_fs_t req; loop = uv_default_loop();