From b714309056cb97c52cf5d859b4ada9b8f5715b27 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 24 Jun 2017 00:18:57 +0200 Subject: [PATCH] Fix bug #74798 pkcs7_en/decrypt does not work if \x0a is used in content The patch for bug #74720 was incomplete. --- ext/openssl/openssl.c | 4 +- ext/openssl/tests/bug74798.phpt | 96 +++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 ext/openssl/tests/bug74798.phpt diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 47bafaf660..cbb2d3a78b 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5387,12 +5387,12 @@ PHP_FUNCTION(openssl_pkcs7_decrypt) goto clean_exit; } - in = BIO_new_file(infilename, "r"); + in = BIO_new_file(infilename, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY)); if (in == NULL) { php_openssl_store_errors(); goto clean_exit; } - out = BIO_new_file(outfilename, "w"); + out = BIO_new_file(outfilename, PHP_OPENSSL_BIO_MODE_W(PKCS7_BINARY)); if (out == NULL) { php_openssl_store_errors(); goto clean_exit; diff --git a/ext/openssl/tests/bug74798.phpt b/ext/openssl/tests/bug74798.phpt new file mode 100644 index 0000000000..5b41af3efc --- /dev/null +++ b/ext/openssl/tests/bug74798.phpt @@ -0,0 +1,96 @@ +--TEST-- +Bug #74798 pkcs7_en/decrypt does not work if \x0a is used in content +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +bool(true) +bool(true) +int(40) +int(40) +int(40) +string(80) "537472696e672077697468200a2077696c6c20656e6420696e206f6e652062797465206d6f72652e" +string(80) "537472696e672077697468200a2077696c6c20656e6420696e206f6e652062797465206d6f72652e" +===DONE=== -- 2.40.0