]> granicus.if.org Git - php/commitdiff
Improved fix for bug #47174 & added a test
authorIlia Alshanetsky <iliaa@php.net>
Sun, 25 Jan 2009 18:27:12 +0000 (18:27 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 25 Jan 2009 18:27:12 +0000 (18:27 +0000)
ext/standard/base64.c
ext/standard/tests/url/bug47174.phpt [new file with mode: 0644]

index 9b835409d19f56ae973ec502e37168d15dc4c731..531be2276c62a4d714852bb86663795679bf9050 100644 (file)
@@ -156,7 +156,6 @@ PHPAPI unsigned char *php_base64_decode_ex(const unsigned char *str, int length,
                                efree(result);
                                return NULL;
                        }
-                       i++;
                        continue;
                }
 
diff --git a/ext/standard/tests/url/bug47174.phpt b/ext/standard/tests/url/bug47174.phpt
new file mode 100644 (file)
index 0000000..6d08063
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #47174 (base64_decode() interprets pad char in mid string as terminator)
+--FILE--
+<?php
+if (base64_decode("dGVzdA==") == base64_decode("dGVzdA==CRAP")) {
+    echo "Same octect data - Signature Valid\n";
+} else {
+    echo "Invalid Signature\n";
+}
+
+$in = base64_encode("foo") . '==' . base64_encode("bar");
+var_dump($in, base64_decode($in));
+
+?>
+--EXPECT--
+Invalid Signature
+string(10) "Zm9v==YmFy"
+string(6) "foobar"