]> granicus.if.org Git - php/commitdiff
Make base64_decode() in non-strict mode binary safe
authorNikita Popov <nikic@php.net>
Fri, 22 Jul 2016 16:20:34 +0000 (18:20 +0200)
committerNikita Popov <nikic@php.net>
Fri, 22 Jul 2016 16:20:34 +0000 (18:20 +0200)
NEWS
ext/standard/base64.c
ext/standard/tests/url/base64_decode_basic_003.phpt

diff --git a/NEWS b/NEWS
index 7eb93e164cef931533948fe8bd83ac139e5992d4..841aade0d7c14cbcbe595387ad68b0f6c7c18c67 100644 (file)
--- 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
index 87cc1e8639c04ee5e022e90c92f824a95222f84d..64f21044e7da7b680df69efaee7214a061410c6d 100644 (file)
@@ -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;
index 981dadede48c05ab100670de9ac5465ff4128b4e..43596757b1cbff503cf15b7c11faf8659c8fc783 100644 (file)
@@ -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