From 3e9fb9f23cdfe5522be3055c63771642fed26630 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 22 Nov 2021 22:56:09 -0700 Subject: [PATCH] LibSanitizer: Check for halt_on_error=0 in $UBSAN_OPTIONS This allows a developer to set the g_ubsan_is_deadly flag to true by default and still disable UBSAN for certain applications. --- Userland/Libraries/LibSanitizer/UBSanitizer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibSanitizer/UBSanitizer.cpp b/Userland/Libraries/LibSanitizer/UBSanitizer.cpp index 15b27b93ee..87941764b1 100644 --- a/Userland/Libraries/LibSanitizer/UBSanitizer.cpp +++ b/Userland/Libraries/LibSanitizer/UBSanitizer.cpp @@ -9,7 +9,6 @@ using namespace AK::UBSanitizer; -// FIXME: Parse option from UBSAN_OPTIONS: halt_on_error=0 or 1 bool AK::UBSanitizer::g_ubsan_is_deadly { false }; #define WARNLN_AND_DBGLN(fmt, ...) \ @@ -34,8 +33,12 @@ static void print_location(const SourceLocation& location) checked_env_for_deadly = true; StringView options = getenv("UBSAN_OPTIONS"); // FIXME: Parse more options and complain about invalid options - if (!options.is_null() && options.contains("halt_on_error=1")) - g_ubsan_is_deadly = true; + if (!options.is_null()) { + if (options.contains("halt_on_error=1")) + g_ubsan_is_deadly = true; + else if (options.contains("halt_on_error=0")) + g_ubsan_is_deadly = false; + } } if (g_ubsan_is_deadly) { WARNLN_AND_DBGLN("UB is configured to be deadly");