mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
pkg/afl++: use usize for len
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// zig_fuzz_test() runs one fuzz iteration on the given input buffer.
|
||||
// The Zig object should export these.
|
||||
void zig_fuzz_init();
|
||||
void zig_fuzz_test(unsigned char*, ssize_t);
|
||||
void zig_fuzz_test(unsigned char*, size_t);
|
||||
|
||||
// Linker-provided symbols marking the boundaries of the __sancov_guards
|
||||
// section. These must be declared extern so the linker provides the actual
|
||||
@@ -132,7 +132,9 @@ int main(int argc, char** argv) {
|
||||
? 0
|
||||
: *__afl_fuzz_len;
|
||||
|
||||
zig_fuzz_test(buf, len);
|
||||
if (len >= 0) {
|
||||
zig_fuzz_test(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
const std = @import("std");
|
||||
const ghostty_vt = @import("ghostty-vt");
|
||||
|
||||
pub export fn zig_fuzz_init() callconv(.c) void {}
|
||||
|
||||
pub export fn zig_fuzz_test(buf: [*]const u8, len: isize) callconv(.c) void {
|
||||
if (len <= 0) return;
|
||||
ghostty_fuzz_parser(buf, @intCast(len));
|
||||
pub export fn zig_fuzz_init() callconv(.c) void {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
pub export fn ghostty_fuzz_parser(
|
||||
input_ptr: [*]const u8,
|
||||
input_len: usize,
|
||||
pub export fn zig_fuzz_test(
|
||||
buf: [*]const u8,
|
||||
len: usize,
|
||||
) callconv(.c) void {
|
||||
var p: ghostty_vt.Parser = .init();
|
||||
defer p.deinit();
|
||||
for (input_ptr[0..input_len]) |byte| _ = p.next(byte);
|
||||
for (buf[0..@intCast(len)]) |byte| _ = p.next(byte);
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void ghostty_fuzz_parser(const uint8_t *input, size_t input_len);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
uint8_t buf[4096];
|
||||
size_t len = 0;
|
||||
FILE *f = stdin;
|
||||
|
||||
if (argc > 1) {
|
||||
f = fopen(argv[1], "rb");
|
||||
if (f == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
len = fread(buf, 1, sizeof(buf), f);
|
||||
|
||||
if (argc > 1) {
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
ghostty_fuzz_parser(buf, len);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user