Skip to content

Commit b50fe89

Browse files
committed
Merge branch 'PHP-7.1'
2 parents e729700 + 0fa40b0 commit b50fe89

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
@@ -86,6 +86,14 @@
8686
#define HAVE_EVP_PKEY_EC 1
8787
#endif
8888

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

9199
/* 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)