From d077c7b29695ce26a45c4f4c0c56690726388d5c Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 17 Jul 2020 07:53:05 -0500 Subject: [PATCH] X509: really looong base64 encoded strings broke extractBER() --- phpseclib/File/X509.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 9295c699..ff4a31a2 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -5144,7 +5144,9 @@ class File_X509 * 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