From 1fec8e3d1356c3e06271f9b911d14f26b08af205 Mon Sep 17 00:00:00 2001 From: Moriyoshi Koizumi Date: Sun, 12 Jan 2003 21:05:22 +0000 Subject: [PATCH] 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. --- ext/standard/filters.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; -- 2.50.1