Closed
Bug 202182
Opened 22 years ago
Closed 22 years ago
Base64InputStream throws EOFException on valid input
Categories
(JSS Graveyard :: Library, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
3.4
People
(Reporter: jamie-bugzilla, Assigned: jamie-bugzilla)
Details
Attachments
(1 file)
2.99 KB,
patch
|
Details | Diff | Splinter Review |
Base64InputStream throws an EOFException on the following valid input:
SW4gdGhlIG1lbW9yeSB5b3UnbGwgZmluZCBtZSwgZXllcyBidX
JuaW5nIHVwLgpUaGUgZGFya25lc3MgaG9sZGluZyBtZSB0aWdo
dGx5LCB1bnRpbCB0aGUgc3VuIHJpc2VzIHVwLgo=
read(byte[], int, int) calls read() repeatedly to get one character of output at
a time. When it gets the final '=', read() returns -1 to signal end of file. But
read(byte[], int, int) already has valid data in its buffer from all the
previous calls to read(), so it returns a positive number. Since the application
hasn't received a -1 (EOF) yet, it calls read(byte[], int, int) again, which
calls read(). But now the state machine is in an invalid state, because it still
thinks it is looking for the 4th character in a 4-byte base64 block. It sees the
end-of-file, which is invalid for that position in the state machine, and throws
an exception.
Assignee | ||
Comment 1•22 years ago
|
||
The solution is to record the end-of-file condition as a separate state in the
state machine. When read() sees a '=' or end-of-file, it sets its state to an
end-of-file state. The next time it is called it realizes it is already at
end-of-file and just returns -1.
Assignee | ||
Comment 2•22 years ago
|
||
Fixed on the trunk:
/cvsroot/mozilla/security/jss/org/mozilla/jss/util/Base64InputStream.java,v <--
Base64InputStream.java
new revision: 1.3; previous revision: 1.2
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•22 years ago
|
Target Milestone: --- → 3.3.1
Assignee | ||
Comment 3•22 years ago
|
||
This won't make it into 3.3, but it will be in 3.4.
Target Milestone: 3.3.1 → 3.4
You need to log in
before you can comment on or make changes to this bug.
Description
•