Skip to content

Commit 0fa40b0

Browse files
committed
group the change for bug #74720
1 parent 6d46528 commit 0fa40b0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ext/openssl/openssl.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
#define HAVE_EVP_PKEY_EC 1
8888
#endif
8989

90+
#ifdef PHP_WIN32
91+
#define PHP_OPENSSL_BIO_MODE_R(flags) (((flags) & PKCS7_BINARY) ? "rb" : "r")
92+
#define PHP_OPENSSL_BIO_MODE_W(flags) (((flags) & PKCS7_BINARY) ? "wb" : "w")
93+
#else
94+
#define PHP_OPENSSL_BIO_MODE_R(flags) "r"
95+
#define PHP_OPENSSL_BIO_MODE_W(flags) "w"
96+
#endif
97+
9098
ZEND_DECLARE_MODULE_GLOBALS(openssl)
9199

92100
/* FIXME: Use the openssl constants instead of
@@ -5008,7 +5016,7 @@ PHP_FUNCTION(openssl_pkcs7_verify)
50085016
goto clean_exit;
50095017
}
50105018

5011-
in = BIO_new_file(filename, (flags & PKCS7_BINARY) ? "rb" : "r");
5019+
in = BIO_new_file(filename, PHP_OPENSSL_BIO_MODE_R(flags));
50125020
if (in == NULL) {
50135021
php_openssl_store_errors();
50145022
goto clean_exit;
@@ -5120,7 +5128,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
51205128
return;
51215129
}
51225130

5123-
infile = BIO_new_file(infilename, (flags & PKCS7_BINARY) ? "rb" : "r");
5131+
infile = BIO_new_file(infilename, PHP_OPENSSL_BIO_MODE_R(flags));
51245132
if (infile == NULL) {
51255133
php_openssl_store_errors();
51265134
goto clean_exit;
@@ -5278,7 +5286,7 @@ PHP_FUNCTION(openssl_pkcs7_sign)
52785286
goto clean_exit;
52795287
}
52805288

5281-
infile = BIO_new_file(infilename, (flags & PKCS7_BINARY) ? "rb" : "r");
5289+
infile = BIO_new_file(infilename, PHP_OPENSSL_BIO_MODE_R(flags));
52825290
if (infile == NULL) {
52835291
php_openssl_store_errors();
52845292
php_error_docref(NULL, E_WARNING, "error opening input file %s!", infilename);

0 commit comments

Comments
 (0)