com php-src: base64_decode: remove redundant chec k: ext/standard/base64.c

From: Date: Tue, 05 Jul 2016 14:51:36 +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-92818@lists.php.net to get a copy of this message
Commit: fbc74bb5f9df22a038a00f1f0e2437f1def81b93 Author: Lauri Kenttä <lauri.kentta@gmail.com> Wed, 25 May 2016 21:15:52 +0300 Committer: Nikita Popov <nikic@php.net> Tue, 5 Jul 2016 16:51:36 +0200 Parents: 59d36bfcf2b3241843883f6f728e1b93224df12a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fbc74bb5f9df22a038a00f1f0e2437f1def81b93 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; }

« previous php.cvs (#92818) next »