aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-02 21:17:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-12-08 17:34:50 +0000
commit06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch)
tree62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
parentcf037972ea8863e2bab7461d77345367d2c1e054 (diff)
parent7fa27ce4a07f19b07799a767fc29416f3b625afb (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
index f9a763d724a8..c26caa647ed9 100644
--- a/contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
+++ b/contrib/llvm-project/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
@@ -364,6 +364,18 @@ Expected<FileBufferByteStream> MSFBuilder::commit(StringRef Path,
FileSize, Layout.SB->BlockSize));
}
+ uint64_t NumDirectoryBlocks =
+ bytesToBlocks(Layout.SB->NumDirectoryBytes, Layout.SB->BlockSize);
+ uint64_t DirectoryBlockMapSize =
+ NumDirectoryBlocks * sizeof(support::ulittle32_t);
+ if (DirectoryBlockMapSize > Layout.SB->BlockSize) {
+ return make_error<MSFError>(msf_error_code::stream_directory_overflow,
+ formatv("The directory block map ({0} bytes) "
+ "doesn't fit in a block ({1} bytes)",
+ DirectoryBlockMapSize,
+ Layout.SB->BlockSize));
+ }
+
auto OutFileOrError = FileOutputBuffer::create(Path, FileSize);
if (auto EC = OutFileOrError.takeError())
return std::move(EC);