[PATCH] D86645: Fix an overflow issue at BackpatchWord
Z via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 10:54:55 PDT 2020
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added reviewers: tejohnson, vitalybuka.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
stephan.yichao.zhao requested review of this revision.
This happens when generating a huge file by LTO, for example, with -gmlt.
When BitNo is > 2^35, ByteNo is overflowed, and an incorrect output offset is overwritten.
This generates ill-formed bitcodes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86645
Files:
llvm/include/llvm/Bitstream/BitstreamWriter.h
Index: llvm/include/llvm/Bitstream/BitstreamWriter.h
===================================================================
--- llvm/include/llvm/Bitstream/BitstreamWriter.h
+++ llvm/include/llvm/Bitstream/BitstreamWriter.h
@@ -103,7 +103,7 @@
/// with the specified value.
void BackpatchWord(uint64_t BitNo, unsigned NewWord) {
using namespace llvm::support;
- unsigned ByteNo = BitNo / 8;
+ uint64_t ByteNo = BitNo / 8;
assert((!endian::readAtBitAlignment<uint32_t, little, unaligned>(
&Out[ByteNo], BitNo & 7)) &&
"Expected to be patching over 0-value placeholders");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86645.288040.patch
Type: text/x-patch
Size: 618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/90655ab6/attachment.bin>
More information about the llvm-commits
mailing list