[libc-commits] [libc] [libc] Add a differential fuzzer for inet_aton (PR #200341)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Mon Jun 1 01:13:08 PDT 2026


================
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Differential fuzz test for llvm-libc inet_aton implementation.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/CPP/scope.h"
+#include "src/arpa/inet/inet_aton.h"
+#include "src/string/memcpy.h"
+#include <arpa/inet.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  // Create a null-terminated copy of the data
+  char *str = new char[size + 1];
+  LIBC_NAMESPACE::cpp::scope_exit delete_str([&] { delete[] str; });
+  LIBC_NAMESPACE::memcpy(str, data, size);
+  str[size] = '\0';
----------------
labath wrote:

No, the functions just read the string.

https://github.com/llvm/llvm-project/pull/200341


More information about the libc-commits mailing list