[compiler-rt] Fix possible underflow in ParseAndSetPath (PR #159389)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 08:54:11 PDT 2025
https://github.com/gbMattN created https://github.com/llvm/llvm-project/pull/159389
If an empty path is passed, the internal_strlen -1 below will loop round to become uptr max. Adding this check ensures that this would be caught
>From 0407fb55e58025e171bb044cb3ff04b67baf1c1a Mon Sep 17 00:00:00 2001
From: Nagy <Matthew.Nagy at sony.com>
Date: Wed, 17 Sep 2025 16:51:59 +0100
Subject: [PATCH] Fix possible underflow in ParseAndSetPath
---
compiler-rt/lib/sanitizer_common/sanitizer_file.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
index 9236a458cdb0e..49a44fa76fc9e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
@@ -106,6 +106,7 @@ static void ParseAndSetPath(const char *pattern, char *dest,
const uptr dest_size) {
CHECK(pattern);
CHECK(dest);
+ CHECK_NE(internal_strcmp(pattern, ""), 0);
CHECK_GE(dest_size, 1);
dest[0] = '\0';
uptr next_substr_start_idx = 0;
More information about the llvm-commits
mailing list