Skip to content

Commit b54e5ac

Browse files
committed
add exception in case of malformed primitive object with indefinite length
1 parent 134152f commit b54e5ac

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ASN1/Decoder/Decoder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ public function fromBinary(&$binaryData, &$offsetIndex = 0)
7373
} else {
7474
if ($contentLength->getLengthForm() === ContentLength::INDEFINITE_FORM) {
7575
for (;;) {
76+
if (\strlen($binaryData) <= $offsetIndex) {
77+
throw new ParserException(
78+
'Can not parse binary from data: Offset index larger than input size',
79+
$offsetIndex
80+
);
81+
}
82+
7683
$firstOctet = $binaryData[$offsetIndex];
7784
$secondOctet = $binaryData[$offsetIndex++];
7885
if ($firstOctet . $secondOctet === \chr(0) . \chr(0)) {

0 commit comments

Comments
 (0)