Closed Bug 11332 Opened 25 years ago Closed 19 years ago

Base64 encoding of byte streams with 8-bit values

Categories

(Grendel Graveyard :: Protocols, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: harning, Assigned: rjkeller)

References

()

Details

There seems to be a problem with the Base64 Encoder, when encoding other that
7-bit streems.

MimeBase64Encoder.java reads

 98       if (buf_bytes == 0)
 99         buf = (buf & 0x00FFFF) | (inb[i] << 16);
100       else if (buf_bytes == 1)
101         buf = (buf & 0xFF00FF) | (inb[i] << 8);
102       else
103         buf = (buf & 0xFFFF00) | (inb[i]);

but should read

 98       if (buf_bytes == 0)
 99         buf = (buf & 0x00FFFF) | (inb[i] << 16);
100       else if (buf_bytes == 1)
101         buf = (buf & 0xFF00FF) | ((in[i] << 8) & 0x00FF00);
102       else
103         buf = (buf & 0xFFFF00) | ((in[i]) & 0x0000FF);

the reason beeing that when shifting a negative value (eg. -122=10000110b) 8
positions left the result becomes 1111111110000110b and not 1000011000000000b
the original code assumes.
Correction:
the reason beeing that when shifting a negative value (eg. -122=10000110b) 8
positions left the result becomes 111111111000011000000000b and not
1000011000000000b the original code assumes.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I just fixed this. Thanks!
Status: RESOLVED → REOPENED
Followup from submitter:

Fine ... I forgot one thing though:
46     (byte)'w', (byte)'x', (byte)'y', (byte)'z', (byte)'', (byte)'1',
(byte)'2', (byte)'3',

(byte)'z', (byte)'', (byte)'1'
should read
(byte)'z', (byte)'0', (byte)'1'
Just entering it in bugzilla until I can fix it.
Cleared the resolution.  (Bugzilla no longer supports the idea that an open bug
can have any kind of resolution set.)
Resolution: FIXED → ---
This bug has not been touched for more than nine months. In most cases, that 
means it has "slipped through the net". Please could the owner take a moment to 
add a comment to the bug with current status, and/or close it.

Thank you :-)

Gerv
Reassigning to nobody@mozilla.org as I'm not working on Grendel anymore.
Assignee: edwin → nobody
Status: REOPENED → NEW
Moving to default owners
Assignee: nobody → rj.keller
QA Contact: talisman
Just confirmed that issue described in comment #3 and description no longer
exist. Looks like edwin checked in the fix and forgot to resolve the bug.

--> FIXED
Status: NEW → RESOLVED
Closed: 25 years ago19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.