[compiler-rt] Fix possible underflow in ParseAndSetPath (PR #159389)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 08:54:45 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: None (gbMattN)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/159389.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_file.cpp (+1)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/159389
More information about the llvm-commits
mailing list