Closed Bug 819927 Opened 7 years ago Closed 7 years ago

mozilla::Base64{Encode,Decode}() should properly handle the empty string

Categories

(Core :: XPCOM, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: tbsaunde, Assigned: tbsaunde)

References

Details

Attachments

(1 file, 1 obsolete file)

PR_Base64{Encode,Decode}() call strlen() on the input if the length is 0, so if you call them with (null, 0, whatever) they crash.
Attached patch patch (obsolete) — Splinter Review
Attachment #690365 - Flags: review?(ehsan)
Comment on attachment 690365 [details] [diff] [review]
patch

Review of attachment 690365 [details] [diff] [review]:
-----------------------------------------------------------------

The nsJSEnvironment.cpp changes don't seem related to this patch.  Also, you should test this in xpcom/tests/TestBase64.cpp.
Attachment #690365 - Flags: review?(ehsan) → review-
> The nsJSEnvironment.cpp changes don't seem related to this patch.  Also, you

oops, sorry about that

> should test this in xpcom/tests/TestBase64.cpp.

that is not exactly easy :( mozilla/Base64.h pulls in headers that are only supposed to be for libxul internal code.

Note that test also needed to be patched to work on !windows too.
Ouch.  Well, nm then I guess.
Attachment #690526 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/mozilla-central/rev/668141ff2577
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
I'm confused. Neil tells me BeginReading should never return null, so why was this change necessary?
You need to log in before you can comment on or make changes to this bug.