com php-src: Make base64_decode() in non-strict mode binary safe: NEWS ext/standard/base64.c ext/standard/tests/url/base64_decode_basic_00 3.phpt
| From: | Nikita Popov | Date: | Fri, 22 Jul 2016 16:20:34 +0000 |
| Subject: | com php-src: Make base64_decode() in non-strict mode binary safe: NEWS ext/standard/base64.c ext/standard/tests/url/base64_decode_basic_00 3.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93330@lists.php.net to get a copy of this message | ||
Commit: bb51da29dc73a5cb9c26e4926d9f0aa4d54f600b
Author: Nikita Popov <nikic@php.net> Fri, 22 Jul 2016 18:20:34 +0200
Parents: e1216f6fc15599ab87ec106b75383efc9b2d8c5b
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bb51da29dc73a5cb9c26e4926d9f0aa4d54f600b
Log:
Make base64_decode() in non-strict mode binary safe
Changed paths:
M NEWS
M ext/standard/base64.c
M ext/standard/tests/url/base64_decode_basic_003.phpt
Diff:
diff --git a/NEWS b/NEWS
index 7eb93e1..841aade 100644
--- a/NEWS
+++ b/NEWS
@@ -7,17 +7,18 @@ PHP NEWS
IntlCalendar and adds a property). (Laruence)
- OpenSSL:
- . Use strict mode when decoding base64 in openssl_decrypt().
+ . Use strict mode when decoding base64 in openssl_decrypt(). (Lauri Kenttä)
- SPL:
. Fixed bug #72646 (SplFileObject::getCsvControl does not return the escape
character). (cmb)
- Standard:
- . Made padding checks in base64_decode() strict mode stricter.
+ . Made base64_decode() padding checks in strict mode stricter. (Lauri Kenttä)
+ . Made base64_decode() in non-strict mode binary safe. (Lauri Kenttä)
- Streams:
- . Use strict mode when decoding base64 in data URIs.
+ . Use strict mode when decoding base64 in data URIs. (Lauri Kenttä)
- XMLRPC:
. Fixed bug #72647 (xmlrpc_encode() unexpected output after referencing
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 87cc1e8..64f2104 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -144,10 +144,6 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t
length
/* run through the whole string, converting as we go */
while (length-- > 0) {
ch = *current++;
- /* stop on null byte in non-strict mode (FIXME: is this really desired?) */
- if (ch == 0 && !strict) {
- break;
- }
if (ch == base64_pad) {
padding++;
continue;
diff --git a/ext/standard/tests/url/base64_decode_basic_003.phpt
b/ext/standard/tests/url/base64_decode_basic_003.phpt
index 981dade..4359675 100644
--- a/ext/standard/tests/url/base64_decode_basic_003.phpt
+++ b/ext/standard/tests/url/base64_decode_basic_003.phpt
@@ -104,14 +104,14 @@ base64 "V*V==" non-strict "U" strict false
base64 "VV*==" non-strict "U" strict false
base64 "VV=*=" non-strict "U" strict false
base64 "VV==*" non-strict "U" strict false
-base64 "\u0000VV==" non-strict "" strict false
-base64 "V\u0000V==" non-strict "" strict false
+base64 "\u0000VV==" non-strict "U" strict false
+base64 "V\u0000V==" non-strict "U" strict false
base64 "VV\u0000==" non-strict "U" strict false
base64 "VV=\u0000=" non-strict "U" strict false
base64 "VV==\u0000" non-strict "U" strict false
-base64 "\u0000VVV==" non-strict "" strict false
-base64 "V\u0000VV==" non-strict "" strict false
-base64 "VV\u0000V==" non-strict "U" strict false
+base64 "\u0000VVV==" non-strict "UU" strict false
+base64 "V\u0000VV==" non-strict "UU" strict false
+base64 "VV\u0000V==" non-strict "UU" strict false
base64 "VVV\u0000==" non-strict "UU" strict false
base64 "VVV=\u0000=" non-strict "UU" strict false
base64 "VVV==\u0000" non-strict "UU" strict false