From: Moriyoshi Koizumi Date: Sun, 12 Jan 2003 21:05:22 +0000 (+0000) Subject: Fixed a bug of the base64 decoder that a sequence of intervening X-Git-Tag: PHP_5_0_dev_before_13561_fix~276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fec8e3d1356c3e06271f9b911d14f26b08af205;p=php Fixed a bug of the base64 decoder that a sequence of intervening characters that are supposed to be ignored by the decoder cause output corruption. --- diff --git a/ext/standard/filters.c b/ext/standard/filters.c index be7346fc2e..9966305c70 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -526,9 +526,6 @@ static php_conv_err_t php_conv_base64_decode_convert(php_conv_base64_decode *ins } if ((pack_bcnt | ustat) == 0) { if (ocnt < 1) { - urem |= (pack << urem_nbits); - urem_nbits += 8; - err = PHP_CONV_ERR_TOO_BIG; break; } @@ -539,6 +536,14 @@ static php_conv_err_t php_conv_base64_decode_convert(php_conv_base64_decode *ins } } + if (urem_nbits >= pack_bcnt) { + urem |= (pack << (urem_nbits - pack_bcnt)); + urem_nbits += (nbitsof_pack - pack_bcnt); + } else { + urem |= (pack >> (pack_bcnt - urem_nbits)); + urem_nbits += (nbitsof_pack - pack_bcnt); + } + inst->urem = urem; inst->urem_nbits = urem_nbits; inst->ustat = ustat;