com php-src: ext/sodium: Use a correct max output size for base64 decoding: ext/sodium/libsodium.c ext/sodium/tests/utils.phpt

From: Date: Sun, 14 Oct 2018 08:37:18 +0000
Subject: com php-src: ext/sodium: Use a correct max output size for base64 decoding: ext/sodium/libsodium.c ext/sodium/tests/utils.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103456@lists.php.net to get a copy of this message
Commit: 15ba7df2245ac177a965346e7ec96a4ab3300839 Author: Frank Denis <github@pureftpd.org> Sun, 14 Oct 2018 10:32:48 +0200 Parents: d05745816634d82a14bb8abb9c322c8b63be098f Branches: PHP-7.2 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=15ba7df2245ac177a965346e7ec96a4ab3300839 Log: ext/sodium: Use a correct max output size for base64 decoding Also handle the case where the function is not available in test. Backport from PECL libsodium-php 2.0.12 Changed paths: M ext/sodium/libsodium.c M ext/sodium/tests/utils.phpt Diff: diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 08ac0f9..a5f892f 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -2780,7 +2780,7 @@ PHP_FUNCTION(sodium_base642bin) "invalid base64 variant identifier", 0); return; } - bin_len = b64_len / 4U * 3U; + bin_len = b64_len / 4U * 3U + 1U; bin = zend_string_alloc(bin_len, 0); if (sodium_base642bin((unsigned char *) ZSTR_VAL(bin), bin_len, b64, b64_len, diff --git a/ext/sodium/tests/utils.phpt b/ext/sodium/tests/utils.phpt index ff380ff..4f99f75 100644 --- a/ext/sodium/tests/utils.phpt +++ b/ext/sodium/tests/utils.phpt @@ -86,6 +86,12 @@ if (defined('SODIUM_BASE64_VARIANT_ORIGINAL')) { } catch (Exception $e) { var_dump('base64("O") case passed'); } + var_dump(sodium_base642bin('YWJjZA', SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING)); +} else { + var_dump('base64("O1R") case passed'); + var_dump('base64("O1") case passed'); + var_dump('base64("O") case passed'); + var_dump('abcd'); } ?> @@ -107,3 +113,4 @@ bool(true) string(25) "base64("O1R") case passed" string(24) "base64("O1") case passed" string(23) "base64("O") case passed" +string(4) "abcd"

« previous php.cvs (#103456) next »