initial commit

Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-05-22 02:40:32 +03:00
commit bba5c8a39a
109 files changed
+14085

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
// libFuzzer harness for the ELF object file reader.
// Build with: cmake -DVOIDLIBC_BUILD_FUZZ=ON ...
// Run: ./fuzz_elf_reader [-max_total_time=60] [corpus_dir]
#include "voidlink/elf_reader.hpp"
#include <cstdint>
#include <cstdio>
#include <sys/syscall.h>
#include <unistd.h>
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) {
// Use memfd so no real file I/O hits disk.
const int fd = static_cast<int>(::syscall(SYS_memfd_create, "fuzz_elf", 0));
if (fd < 0) return 0;
const std::uint8_t* p = data;
std::size_t rem = size;
while (rem > 0) {
const ssize_t n = ::write(fd, p, rem);
if (n <= 0) break;
p += static_cast<std::size_t>(n);
rem -= static_cast<std::size_t>(n);
}
char path[64];
std::snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
(void)voidlibc::voidlink::elf::parse_elf64_object(path);
::close(fd);
return 0;
}