Re: [gnet] Re: [gnet-dev] gnet_base64_encode version 2.0.5



Your patch won't work.

output[1] must be less than 64. If input[0] is b00000011, output[3] will be at least b11xxxxxx, which is greater than 64.

David


On Oct 27, 2004, at 8:55 AM, fredo wrote:
The 2.0.5's gnet_base64_encode function is buggy. Has
anybody fixed it?

I encoded "A\x84\0", the result was "QIQA". That
result was incorrect. The correct result is "QYQA"

I have fixed gnet_base64_encode in my libgnet code
tree. But I created the function from scratch, not
based from the 2.0.5's gnet_base64_encode.

since i have been cooked up that code here is the fix.
change the line:

      output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);

to:

      output[1] = ((input[0] & 0x03) << 6) + (input[1] >> 2);


sorry, but i cant do cvs nor diff at the moment.

--
David Helder - dhelder gizmolabs org - http://www.gizmolabs.org/~dhelder




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]