From d80cfa6f41b358440cc0ed021deaa01583a035d7 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Fri, 11 Apr 2025 21:37:01 +0200 Subject: [PATCH] Compilation: Use trapping UBSan if -fno-ubsan-rt is passed. This is a mitigation of #23216 meant only for 0.14.x. --- src/Compilation.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 84dafa59af..df0b060570 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6053,7 +6053,9 @@ pub fn addCCArgs( // function was called. try argv.append("-fno-sanitize=function"); - if (mod.optimize_mode == .ReleaseSafe) { + // If we want to sanitize C, but the ubsan runtime has been turned off, + // we'll switch to just trapping. + if (comp.ubsan_rt_strat == .none or mod.optimize_mode == .ReleaseSafe) { // It's recommended to use the minimal runtime in production // environments due to the security implications of the full runtime. // The minimal runtime doesn't provide much benefit over simply