mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-15 17:57:12 +00:00
ASN1: fix infinite loop during ASN1 decode process
This commit is contained in:
parent
e6a2ce1d6d
commit
5c2ffd2544
@ -366,7 +366,7 @@ class File_ASN1
|
||||
$newcontent = array();
|
||||
$remainingLength = $length;
|
||||
while ($remainingLength > 0) {
|
||||
$temp = $this->_decode_ber($content, $start);
|
||||
$temp = $this->_decode_ber($content, $start, $content_pos);
|
||||
$length = $temp['length'];
|
||||
// end-of-content octets - see paragraph 8.1.5
|
||||
if (substr($content, $content_pos + $length, 2) == "\0\0") {
|
||||
|
@ -289,4 +289,14 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
||||
$this->assertInternalType('array', $decoded);
|
||||
$this->assertCount(0, $decoded[0]['content']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group github1027
|
||||
*/
|
||||
public function testInfiniteLoop()
|
||||
{
|
||||
$asn1 = new File_ASN1();
|
||||
$data = base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw==');
|
||||
$asn1->decodeBER($data);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user