[clang-tools-extra] [clang-tidy] Fix buffer overflow in compareHeaders (PR #87213)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 31 18:44:41 PDT 2024
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/87213
`RHS` can be shorter than `LHS`.
Reported by asan after #83440.
>From a6d57814761cb74de98b40a4cc3acdd9b262e854 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sun, 31 Mar 2024 18:42:25 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index b6d9c50d0b109c..a44720c47eca2d 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -108,7 +108,7 @@ int compareHeaders(StringRef LHS, StringRef RHS,
IncludeSorter::IncludeStyle Style) {
if (Style == IncludeSorter::IncludeStyle::IS_Google_ObjC) {
const std::pair<const char *, const char *> &Mismatch =
- std::mismatch(LHS.begin(), LHS.end(), RHS.begin());
+ std::mismatch(LHS.begin(), LHS.end(), RHS.begin(), RHS.end());
if ((Mismatch.first != LHS.end()) && (Mismatch.second != RHS.end())) {
if ((*Mismatch.first == '.') && (*Mismatch.second == '+')) {
return -1;
More information about the cfe-commits
mailing list