Closed
Bug 53792
Opened 24 years ago
Closed 24 years ago
nsDataChannel::ParseData() calculates the wrong length on the base64 decoded data
Categories
(Core :: Networking, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: sspitzer, Assigned: sspitzer)
References
()
Details
Attachments
(1 file)
710 bytes,
patch
|
Details | Diff | Splinter Review |
I'm working on something that uses data: urls
basically, I build up a data url with a spec like this:
"data:text/html;base64,<foo>"
where <foo> is base 64 encoded html follows, encoded with PL_Base64Encode().
I've noticed that when I run the data url and <foo> comes back decoded, extra
junk is at the end.
I've traced it down, and the problem is in nsDataChannel::ParseData()
see line 187 on nsDataChannel.cpp:
dataToWrite->dataLen = resultLen;
If you look at how resultLen is calculated, it is way too big. (it's about the
size of the *encoded* data. it should be the size of the decoded data.)
This fix is working for me:
dataToWrite->dataLen = PL_strlen(decodedData);
PL_Base64Decode() will null terminate the buffer since we pass null for the 3rd
parameter.
Do you think this could be causing any other bugs?
my code that uses this isn't checked in yet, but I'd need to fix this before I
do check in.
Assignee | ||
Comment 1•24 years ago
|
||
Assignee | ||
Comment 2•24 years ago
|
||
valeski, mscott, can you review the patch?
for an explanation see my original comments in the bug report.
Keywords: patch
Comment 3•24 years ago
|
||
sr=mscott
Assignee | ||
Comment 5•24 years ago
|
||
fixed. I'll come up with at data url that tever can use to verify.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 6•24 years ago
|
||
to reproduce, click here:
data:text/html;base64,VGhpcyBpcyBhIHRlc3QK
before the fix, you'd see:
"This is a test ýýýý"
after, you should see
"This is a test"
Comment 7•24 years ago
|
||
Seth, is this platform specific? This seems to work on my rtm builds on Linux
and NT. I do see some trailing garbage characters on the mac though.
Comment 8•24 years ago
|
||
oh wait, sorry I just had to hit reload and it was their. Will check your patch
on tomorrows build .
Assignee | ||
Comment 9•24 years ago
|
||
the bug is XP. the trailing garbage is not guaranteed, but common.
we can try other data urls to convince you.
try
data:text/html;base64,YSBzbGlnaHRseSBsb25nZXIgdGVzdCBmb3IgdGV2ZXIK
fyi, heres how I generate the base64 data:
$ echo "a slightly longer test for tever" > foo
$ uuencode -m foo test
begin-base64 664 test
YSBzbGlnaHRseSBsb25nZXIgdGVzdCBmb3IgdGV2ZXIK
====
Comment 10•24 years ago
|
||
ok thanks, both of those examples work on my three test platforms
Verified
WinNT4 2000113004-Mtrunk
Linux rh6 2000113006-Mtrunk
Mac os9 2000113008-Mtrunk
Status: RESOLVED → VERIFIED
Comment 11•24 years ago
|
||
*** Bug 47288 has been marked as a duplicate of this bug. ***
Comment 12•24 years ago
|
||
This bug's resolution introduced a new one. Please refer to bug 78876
You need to log in
before you can comment on or make changes to this bug.
Description
•