aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ByteArrayOutputStream.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-09 04:45:14 -0500
committerLoki Rautio <lokirautio@gmail.com>2026-03-09 04:45:14 -0500
commitd557ca2dfba5ffcca99ceb41b07d149f871964b5 (patch)
tree89ef5bd5fdb2a86fe10a5dead65b65bce8aa0a1d /Minecraft.World/ByteArrayOutputStream.cpp
parent0c4f4599045edad935403e4d79d28f6b9aa95833 (diff)
LCEMP RCE fixes
Based on commit d017bfc30a68888bf5c79b23cf5c4f607cf828bf
Diffstat (limited to 'Minecraft.World/ByteArrayOutputStream.cpp')
-rw-r--r--Minecraft.World/ByteArrayOutputStream.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Minecraft.World/ByteArrayOutputStream.cpp b/Minecraft.World/ByteArrayOutputStream.cpp
index a9f36e04..a6fdad8f 100644
--- a/Minecraft.World/ByteArrayOutputStream.cpp
+++ b/Minecraft.World/ByteArrayOutputStream.cpp
@@ -53,9 +53,25 @@ void ByteArrayOutputStream::write(byteArray b, unsigned int offset, unsigned int
{
assert( b.length >= offset + length );
+ if (offset > b.length || length > b.length - offset)
+ {
+ return;
+ }
+
+ if (length > 0xFFFFFFFF - count)
+ {
+ return;
+
// If we will fill the buffer we need to make it bigger
if( count + length >= buf.length )
- buf.resize( max( count + length + 1, buf.length * 2 ) );
+ {
+ unsigned int newSize = (std::max)(count + length + 1, buf.length * 2);
+ if (newSize <= buf.length)
+ {
+ return;
+ }
+ buf.resize(newSize);
+ }
XMemCpy( &buf[count], &b[offset], length );
//std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // Or this instead?