Skip to content

Commit b60b660

Browse files
committed
fix: trap on UB with -fsanitize-trap=undefined
1 parent a2bb61f commit b60b660

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

build.zig

+20-5
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,13 @@ pub fn build(b: *std.Build) !void {
491491
});
492492
socketfuzz_lib.addCSourceFile(.{
493493
.file = AFLplusplus_utl_path.path(b, "socket_fuzzing/socketfuzz.c"),
494-
.flags = &.{ if (ptr_bit_width == 32) "-m32" else "-m64", "-Wall", "-Wextra", "-fno-sanitize=undefined" },
494+
.flags = &.{
495+
if (ptr_bit_width == 32) "-m32" else "-m64",
496+
"-Wall",
497+
"-Wextra",
498+
"-fsanitize=undefined",
499+
"-fsanitize-trap=undefined",
500+
},
495501
});
496502
socketfuzz_lib.addIncludePath(AFLplusplus_inc_path);
497503
socketfuzz_lib.linkLibC();
@@ -511,7 +517,13 @@ pub fn build(b: *std.Build) !void {
511517
});
512518
argvfuzz_lib.addCSourceFile(.{
513519
.file = AFLplusplus_utl_path.path(b, "argv_fuzzing/argvfuzz.c"),
514-
.flags = &.{ if (ptr_bit_width == 32) "-m32" else "-m64", "-Wall", "-Wextra", "-fno-sanitize=undefined" },
520+
.flags = &.{
521+
if (ptr_bit_width == 32) "-m32" else "-m64",
522+
"-Wall",
523+
"-Wextra",
524+
"-fsanitize=undefined",
525+
"-fsanitize-trap=undefined",
526+
},
515527
});
516528
argvfuzz_lib.addIncludePath(AFLplusplus_inc_path);
517529
argvfuzz_lib.linkLibC();
@@ -575,7 +587,8 @@ const EXE_FLAGS = .{
575587
"-Wno-pointer-sign",
576588
"-Wno-pointer-arith",
577589
"-Wno-variadic-macros",
578-
"-fno-sanitize=undefined",
590+
"-fsanitize=undefined",
591+
"-fsanitize-trap=undefined",
579592
"-DDOC_PATH=\"\"",
580593
"-D_AFL_SPECIAL_PERFORMANCE",
581594
};
@@ -591,7 +604,8 @@ const LLVM_EXE_C_FLAGS = .{
591604
"-Wno-unused-result",
592605
"-Wno-unused-function",
593606
"-Wno-variadic-macros",
594-
"-fno-sanitize=undefined",
607+
"-fsanitize=undefined",
608+
"-fsanitize-trap=undefined",
595609
"-Wno-deprecated-copy-with-dtor",
596610
"-DUSE_BINDIR=1",
597611
"-DAFL_REAL_LD=\"lld\"",
@@ -634,6 +648,7 @@ const UTIL_LIB_FLAGS = .{
634648
"-funroll-loops",
635649
"-Wall",
636650
"-Wno-pointer-sign",
637-
"-fno-sanitize=undefined",
651+
"-fsanitize=undefined",
652+
"-fsanitize-trap=undefined",
638653
"-D_FORTIFY_SOURCE=2",
639654
};

0 commit comments

Comments
 (0)