From cbe73b3cfe5945926c8d91dcc0884ce7524764eb Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 9 Jun 2017 17:35:37 +0200 Subject: [PATCH] Fixed bug #74720 pkcs7_en/decrypt does not work if \x1a is used in content --- ext/openssl/openssl.c | 4 +- ext/openssl/tests/bug74720_0.phpt | 93 +++++++++++++++++++++++++++++++ ext/openssl/tests/bug74720_1.phpt | 88 +++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 ext/openssl/tests/bug74720_0.phpt create mode 100644 ext/openssl/tests/bug74720_1.phpt diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index f9d022a6575..4adf9cb8f99 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 00000000000..d84dc47d771 --- /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 00000000000..9a8099a33ce --- /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== +