aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.h
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2015-02-22 19:32:03 +0000
committerJF Bastien <jfb@google.com>2015-02-22 19:32:03 +0000
commit30bf96bfe7963f0a45207bb73adc15d92187e0e6 (patch)
tree86405e0198340fbdb6d9a6f82ecc7063d92d2f6e /llvm/lib/Bitcode/Reader/BitcodeReader.h
parent4b1482e75c1787e509aac986e2c8f2355e98fb74 (diff)
downloadllvm-30bf96bfe7963f0a45207bb73adc15d92187e0e6.zip
llvm-30bf96bfe7963f0a45207bb73adc15d92187e0e6.tar.gz
llvm-30bf96bfe7963f0a45207bb73adc15d92187e0e6.tar.bz2
Use common parse routine to read alignment values from bitcode
While fuzzing LLVM bitcode files, I discovered that (1) the bitcode reader doesn't check that alignments are no larger than 2**29; (2) downstream code doesn't check the range; and (3) for values out of range, corresponding large memory requests (based on alignment size) will fail. This code fixes the bitcode reader to check for valid alignments, fixing this problem. This CL fixes alignment value on global variables, functions, and instructions: alloca, load, load atomic, store, store atomic. Patch by Karl Schimpf (kschimpf@google.com). llvm-svn: 230180
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h
index 5090be4..9803e78 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.h
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h
@@ -335,6 +335,10 @@ private:
return getFnValueByID(ValNo, Ty);
}
+ /// Converts alignment exponent (i.e. power of two (or zero)) to the
+ /// corresponding alignment to use. If alignment is too large, returns
+ /// a corresponding error code.
+ std::error_code parseAlignmentValue(uint64_t Exponent, unsigned &Alignment);
std::error_code ParseAttrKind(uint64_t Code, Attribute::AttrKind *Kind);
std::error_code ParseModule(bool Resume);
std::error_code ParseAttributeBlock();