1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

base64_decode: strict: Fail on truncated input

This commit is contained in:
Lauri Kenttä
2016-07-11 12:40:07 +03:00
committed by Nikita Popov
parent 0981e5de3c
commit 586a0761ff
2 changed files with 9 additions and 5 deletions

View File

@@ -193,6 +193,10 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
}
i++;
}
/* fail if the input is truncated (only one char in last group) */
if (strict && i % 4 == 1) {
goto fail;
}
ZSTR_LEN(result) = j;
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';

View File

@@ -95,13 +95,13 @@ Error: 8 - Undefined variable: undefined_var, %s(%d)
Error: 8 - Undefined variable: unset_var, %s(%d)
-- Arg value 0 --
string(0) ""
bool(false)
-- Arg value 1 --
string(0) ""
bool(false)
-- Arg value 12345 --
string(6) "d76df8"
bool(false)
-- Arg value -2345 --
bool(false)
@@ -148,13 +148,13 @@ string(0) ""
string(0) ""
-- Arg value true --
string(0) ""
bool(false)
-- Arg value false --
string(0) ""
-- Arg value TRUE --
string(0) ""
bool(false)
-- Arg value FALSE --
string(0) ""