com php-src: base64_decode: remove redundant chec k: ext/standard/base64.c
| From: | Nikita Popov | Date: | Wed, 06 Jul 2016 23:27:23 +0000 |
| Subject: | com php-src: base64_decode: remove redundant chec k: ext/standard/base64.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92852@lists.php.net to get a copy of this message | ||
Commit: ef6f1631610c5314062336648e13a3eb76bb564c
Author: Lauri Kenttä <lauri.kentta@gmail.com> Wed, 25 May 2016 21:15:52 +0300
Committer: Nikita Popov <nikic@php.net> Thu, 7 Jul 2016 01:27:23 +0200
Parents: c65de8ac1302a3b9825a6abe19c87fe45c68698a
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ef6f1631610c5314062336648e13a3eb76bb564c
Log:
base64_decode: remove redundant check
If length == 0 || *current != '=' is false, the for loop will always
end up in this same point, until the if statement becomes true.
Thus, the if statement is not needed.
Changed paths:
M ext/standard/base64.c
Diff:
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 352e7ea..e8d7f04 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -145,12 +145,13 @@ 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++) != '\0') {
if (ch == base64_pad) {
+ /* fail if the padding character is second in a group (like V===) */
+ /* FIXME: why do we still allow invalid padding in other places in the middle of the string? */
if (i % 4 == 1) {
- if (length == 0 || *current != '=') {
- zend_string_free(result);
- return NULL;
- }
- } else if (length > 0 && *current != '=' && strict) {
+ zend_string_free(result);
+ return NULL;
+ }
+ if (length > 0 && *current != '=' && strict) {
while (--length > 0 && isspace(*++current)) {
continue;
}