Re: APR::Base64 Bug
[prev]
[thread]
[next]
[Date index for 2005/05/23]
--nextPart1464249.TnEP20T76U
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
On Sunday 22 May 2005 19:18, Torsten Foertsch wrote:
> Hi,
>
> there is something wrong with APR::Base64.
>
> r2@opi:~> perl -MAPR::Base64 -MData::Dumper -e '$x=3DAPR::Base64::encode(=
"x"
> ); print "$x\n".Dumper( [split "", $x] ), "length=3D".length($x)."\n";' e=
A=3D=3D
> $VAR1 =3D [
> 'e',
> 'A',
> '=3D',
> '=3D',
> ''
> ];
> length=3D5
> r2@opi:~> perl -MAPR::Base64 -MData::Dumper -e '$x=3DAPR::Base64::encode(
> "xxx" ); print "$x\n".Dumper( [split "", $x] ), "length=3D".length($x)."\=
n";'
> eHh4
> $VAR1 =3D [
> 'e',
> 'H',
> 'h',
> '4',
> ''
> ];
> length=3D5
>
> In both cases length should be 4 and split("",$x) should return (qw(e a =
=3D
> =3D)).
The problem is apr_base64_encode_len() returns the length including the=20
trailing \0 required to hold the encoded string.
This patch cures the problem:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=2D-- xs/APR/Base64/APR__Base64.h 2005-04-26 20:58:34.000000000 +0200
+++ xs/APR/Base64/APR__Base64.h 2005-05-23 22:05:53.416525123 +0200
@@ -18,9 +18,9 @@
STRLEN len;
int encoded_len;
char *data =3D SvPV(arg, len);
=2D mpxs_sv_grow(sv, apr_base64_encode_len(len));
+ mpxs_sv_grow(sv, apr_base64_encode_len(len)-1);
encoded_len =3D apr_base64_encode_binary(SvPVX(sv), data, len);
=2D mpxs_sv_cur_set(sv, encoded_len);
+ mpxs_sv_cur_set(sv, encoded_len-1);
}
static MP_INLINE void mpxs_apr_base64_decode(pTHX_ SV *sv, SV *arg)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
but now the APR::Base64::encode_len test fails because it calls simply=20
apr_base64_encode_len().
To cure that a new function needs to be introduced in=20
xs/APR/Base64/APR__Base64.h ...
I'd do that but I don't know what to call instead of mpxs_sv_cur_set() if I=
=20
want to set an IV.
Torsten
--nextPart1464249.TnEP20T76U
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQBCkjn/wicyCTir8T4RAkSRAJ0RE3hOAfQDThSgnc+uKzmYeS/KtwCghydb
pF27bwQdJJR0PmpJwCOcpX4=
=0Mnl
-----END PGP SIGNATURE-----
--nextPart1464249.TnEP20T76U--
 |
(message missing)
|
 |
 |
Re: APR::Base64 Bug
Torsten Foertsch 20:15 on 23 May 2005
|