[PATCH] D139315: [NFC][LLVM-MT] Fix buffer-overflow when comparing buffers
Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 02:31:30 PST 2022
jmmartinez updated this revision to Diff 480402.
jmmartinez added a comment.
In fact, bring back the size comparison to speed up the comparison in the case the sizes do not match
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139315/new/
https://reviews.llvm.org/D139315
Files:
llvm/tools/llvm-mt/llvm-mt.cpp
Index: llvm/tools/llvm-mt/llvm-mt.cpp
===================================================================
--- llvm/tools/llvm-mt/llvm-mt.cpp
+++ llvm/tools/llvm-mt/llvm-mt.cpp
@@ -150,9 +150,12 @@
bool Same = false;
if (OutBuffOrErr) {
const std::unique_ptr<MemoryBuffer> &FileBuffer = *OutBuffOrErr;
- Same = std::equal(OutputBuffer->getBufferStart(),
- OutputBuffer->getBufferEnd(),
- FileBuffer->getBufferStart());
+ bool SameSize =
+ OutputBuffer->getBufferSize() == FileBuffer->getBufferSize();
+ Same = SameSize && std::equal(OutputBuffer->getBufferStart(),
+ OutputBuffer->getBufferEnd(),
+ FileBuffer->getBufferStart(),
+ FileBuffer->getBufferEnd());
}
if (!Same) {
#if LLVM_ON_UNIX
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139315.480402.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/2eabbc5d/attachment.bin>
More information about the llvm-commits
mailing list