Skip to content

Commit 4417383

Browse files
benhillisBen Hillis
andauthored
socketshared: add maximum message size to avoid very large allocations (#40050)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
1 parent 625a44a commit 4417383

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/shared/inc/socketshared.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ try
6464
#endif
6565
}
6666

67+
if (MessageSize > 4 * 1024 * 1024) // 4 MiB
68+
{
69+
#if defined(_MSC_VER)
70+
THROW_HR_MSG(E_UNEXPECTED, "Message size too large: %llu", MessageSize);
71+
#elif defined(__GNUC__)
72+
THROW_UNEXCEPTED();
73+
#endif
74+
}
75+
6776
if (Buffer.size() < MessageSize)
6877
{
6978
Buffer.resize(MessageSize);

0 commit comments

Comments
 (0)