Skip to content

Commit 20b5eee

Browse files
committed
don't accept lists/arrays longer than 0x7fffffff
1 parent 6d8123e commit 20b5eee

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Tag/ArrayValueTag.php

+5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ abstract class ArrayValueTag extends Tag implements Iterator, ArrayAccess, Count
1717

1818
/**
1919
* @inheritDoc
20+
* @throws Exception
2021
*/
2122
public function generatePayload(NbtSerializer $serializer): string
2223
{
24+
$count = $this->count();
25+
if($count > 0x7fffffff) {
26+
throw new \Exception("Array exceeds maximum length of " . 0x7fffffff . " entries");
27+
}
2328
return $serializer->encodeLengthPrefix($this->count()) . $this->generateValues($serializer);
2429
}
2530

0 commit comments

Comments
 (0)