Skip to content

Commit

Permalink
X509: really looong base64 encoded strings broke extractBER()
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Jul 17, 2020
1 parent d8e39b0 commit d077c7b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion phpseclib/File/X509.php
Expand Up @@ -5144,7 +5144,9 @@ function _extractBER($str)
* subject=/O=organization/OU=org unit/CN=common name
* issuer=/O=organization/CN=common name
*/
$temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
$temp = strlen($str) <= ini_get('pcre.backtrack_limit') ?
preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1) :
$str;
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
$temp = preg_replace('#-+[^-]+-+#', '', $temp);
// remove new lines
Expand Down

1 comment on commit d077c7b

@terrafrost
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1486

Please sign in to comment.