diff options
| author | Lauri Kenttä <lauri.kentta@gmail.com> | 2016-05-25 21:15:52 +0300 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2016-07-07 01:27:23 +0200 |
| commit | ef6f1631610c5314062336648e13a3eb76bb564c (patch) | |
| tree | 4fcca2014e8ae0f24631e39c31d91c768c83f511 | |
| parent | c65de8ac1302a3b9825a6abe19c87fe45c68698a (diff) | |
| download | php-git-ef6f1631610c5314062336648e13a3eb76bb564c.tar.gz | |
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.
| -rw-r--r-- | ext/standard/base64.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/standard/base64.c b/ext/standard/base64.c index 352e7ea52c..e8d7f04aa4 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; } |
