cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problem in base64 Implementation

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 4 Dec 2009 19:46:08 +0100 (CET)

On Fri, 4 Dec 2009, p c wrote:

> I have been going through curl sources, and came across base64 encode and
> decode implementation in lib/base64.c. I am not sure which workflow it will
> hit, but the implementation seems wrong to me.

Not to me. Can you please provide an actual code sample or set of inputs that
will make it behave wrongly?

> What happens is if my data is not a multiple of 3, line 193 causes problem
>
> 193 for (i = inputparts = 0; i < 3; i++) {

No, the rest of the code doesn't mishave due to that as far as I can see.

> It tend to pick up noise from the end of the array and encode that also!

No, as it'll only use data from the input as long as insize is greater than
zero. Your suggested "fix" will however cause it to misbehave...

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-04