From: Anatol Belski Date: Fri, 9 Jun 2017 15:35:37 +0000 (+0200) Subject: Fixed bug #74720 pkcs7_en/decrypt does not work if \x1a is used in X-Git-Tag: php-7.1.7RC1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbe73b3cfe5945926c8d91dcc0884ce7524764eb;p=php Fixed bug #74720 pkcs7_en/decrypt does not work if \x1a is used in content --- diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index f9d022a657..4adf9cb8f9 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5120,7 +5120,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) return; } - infile = BIO_new_file(infilename, "r"); + infile = BIO_new_file(infilename, (flags & PKCS7_BINARY) ? "rb" : "r"); if (infile == NULL) { php_openssl_store_errors(); goto clean_exit; @@ -5278,7 +5278,7 @@ PHP_FUNCTION(openssl_pkcs7_sign) goto clean_exit; } - infile = BIO_new_file(infilename, "r"); + infile = BIO_new_file(infilename, (flags & PKCS7_BINARY) ? "rb" : "r"); if (infile == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "error opening input file %s!", infilename); diff --git a/ext/openssl/tests/bug74720_0.phpt b/ext/openssl/tests/bug74720_0.phpt new file mode 100644 index 0000000000..d84dc47d77 --- /dev/null +++ b/ext/openssl/tests/bug74720_0.phpt @@ -0,0 +1,93 @@ +--TEST-- +Bug #74720 pkcs7_en/decrypt does not work if \x1a is used in content, variant 0 +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECTF-- +bool(true) +bool(true) +int(39) +int(39) +int(39) +==DONE== + diff --git a/ext/openssl/tests/bug74720_1.phpt b/ext/openssl/tests/bug74720_1.phpt new file mode 100644 index 0000000000..9a8099a33c --- /dev/null +++ b/ext/openssl/tests/bug74720_1.phpt @@ -0,0 +1,88 @@ +--TEST-- +Bug #74720 pkcs7_en/decrypt does not work if \x1a is used in content, variant 1 +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECTF-- +bool(true) +==DONE== +