[compiler-rt] Fix possible underflow in ParseAndSetPath (PR #159389)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 07:11:02 PDT 2025
https://github.com/gbMattN updated https://github.com/llvm/llvm-project/pull/159389
>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 1/2] 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;
>From a2db4001a2d686b42cde97918ffbf10644f5a79a Mon Sep 17 00:00:00 2001
From: Nagy <Matthew.Nagy at sony.com>
Date: Thu, 18 Sep 2025 15:10:50 +0100
Subject: [PATCH 2/2] Alter check to return an empty string
---
compiler-rt/lib/sanitizer_common/sanitizer_file.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
index 49a44fa76fc9e..6a82af1b4270d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
@@ -106,9 +106,11 @@ 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';
+ // Return empty string if empty string was passed
+ if (internal_strcmp(pattern, "") == 0)
+ return;
uptr next_substr_start_idx = 0;
for (uptr i = 0; i < internal_strlen(pattern) - 1; i++) {
if (pattern[i] != '%')
More information about the llvm-commits
mailing list