1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-30 04:39:02 +01:00

ASN1: fix infinite loop during ASN1 decode process

This commit is contained in:
terrafrost 2016-08-28 10:38:01 -05:00
parent e6a2ce1d6d
commit 5c2ffd2544
2 changed files with 11 additions and 1 deletions

View File

@ -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") {

View File

@ -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);
}
}