summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-06-07 18:42:39 +0000
committerZachary Turner <zturner@google.com>2016-06-07 18:42:39 +0000
commit5839503f08d31b52311d7d38df0631693573df9e (patch)
treee3517a6de6e4056b4a9127fd350860bbfeb23d91
parent930e031d64ea8e32792c05402080c4f85a218df5 (diff)
downloadbcm5719-llvm-5839503f08d31b52311d7d38df0631693573df9e.tar.gz
bcm5719-llvm-5839503f08d31b52311d7d38df0631693573df9e.zip
[pdb] Fix a potential overflow and remove unnecessary comments.
llvm-svn: 272043
-rw-r--r--llvm/include/llvm/DebugInfo/CodeView/StreamReader.h3
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp3
2 files changed, 3 insertions, 3 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h b/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h
index 0cd779419c5..a42cc8bc7b8 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h
@@ -60,6 +60,9 @@ public:
return Error::success();
}
+ if (NumElements > UINT32_MAX/sizeof(T))
+ return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
+
if (auto EC = readBytes(Bytes, NumElements * sizeof(T)))
return EC;
Array = ArrayRef<T>(reinterpret_cast<const T *>(Bytes.data()), NumElements);
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index 81762e7f879..9ef0a492e87 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -210,10 +210,7 @@ Error PDBFile::parseStreamData() {
if (DirectoryStream)
return Error::success();
- // bool SeenNumStreams = false;
uint32_t NumStreams = 0;
- // uint32_t StreamIdx = 0;
- // uint64_t DirectoryBytesRead = 0;
const SuperBlock *SB = Context->SB;
OpenPOWER on IntegriCloud