Author: Vitaly Buka Date: 2024-03-31T21:24:05-07:00 New Revision: a21e0ba192147af4968742785f375dba0e3ea768
URL: https://github.com/llvm/llvm-project/commit/a21e0ba192147af4968742785f375dba0e3ea768 DIFF: https://github.com/llvm/llvm-project/commit/a21e0ba192147af4968742785f375dba0e3ea768.diff LOG: [clang-tidy] Fix buffer overflow in compareHeaders (#87213) `RHS` can be shorter than `LHS`. Reported by asan after #83440. Added: Modified: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp Removed: ################################################################################ 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits