Closed
Bug 377049
Opened 19 years ago
Closed 19 years ago
nsBaseURLParser::ParsePath doesn't handle strings that are not NULL terminated
Categories
(Core :: Networking, defect)
Core
Networking
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha5
People
(Reporter: brettw, Assigned: sciguyryan)
Details
Attachments
(1 file, 2 obsolete files)
|
1.08 KB,
patch
|
Biesinger
:
review+
|
Details | Diff | Splinter Review |
The URL parsing code is written such that the input may or may not be NULL terminated. However, the first for loop in nsBaseURLParser::ParsePath uses a NULL for the termination condition, which will cause us to read random memory if the input isn't NULL terminated.
In practice, this code seems to be only be run over the output of PromiseFlatCString which guarantees a NULL terminator. However, this may be a problem in the future, especially since the parsers go pretty far out of their way to allow non-NULL terminated input.
| Assignee | ||
Comment 1•19 years ago
|
||
One simple fix here would be to create a new |PromiseFlatCString| string from the character string passes as the argument then re-convert this back too a |const char*| array and use that thus ensuring we always end with a string but that seems inefficient.
I'm not sure if the above method is viable though.
| Assignee | ||
Comment 2•19 years ago
|
||
Patch v1.0
This is probably nicer than the method above because we don't need to duplicate code there and we simply check against the |pathLen| parameter instead.
Comment 3•19 years ago
|
||
Comment on attachment 261465 [details] [diff] [review]
patch v1.0
p != path + pathLen. did you test this patch?
Attachment #261465 -
Flags: review?(cbiesinger) → review-
| Assignee | ||
Updated•19 years ago
|
Attachment #261465 -
Flags: review-
| Assignee | ||
Comment 4•19 years ago
|
||
Patch v1.1
Oops!
Attachment #261465 -
Attachment is obsolete: true
Attachment #261484 -
Flags: review?(cbiesinger)
Updated•19 years ago
|
Attachment #261484 -
Flags: review?(cbiesinger) → review+
| Assignee | ||
Updated•19 years ago
|
Whiteboard: [checkin needed]
Comment 5•19 years ago
|
||
mozilla/netwerk/base/src/nsURLParsers.cpp 1.27
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: --- → mozilla1.9alpha4
Comment 6•19 years ago
|
||
Please set in-testsuite to either "-" or "?", depending on whether this needs a regression test.
Comment 7•19 years ago
|
||
Comment on attachment 261484 [details] [diff] [review]
Patch v1.1
>- for (p = path; *p; ++p) {
>+ for (p = path; p < path + pathLen; ++p)
This fails to compile, backed out.
| Assignee | ||
Comment 8•19 years ago
|
||
Sorry for the trouble everyone - I missed this one because my build file strangely has the missing |{| already so I'm not sure how its missing from the patch.
I'm going to ask biesi to re-review this patch just to be on the safe side.
Attachment #261484 -
Attachment is obsolete: true
Attachment #262798 -
Flags: review?(cbiesinger)
Updated•19 years ago
|
Attachment #262798 -
Flags: review?(cbiesinger) → review+
| Assignee | ||
Updated•19 years ago
|
Status: RESOLVED → REOPENED
Flags: in-testsuite-
Resolution: FIXED → ---
Whiteboard: [checkin needed]
Comment 9•19 years ago
|
||
this should get a testcase, though we don't have a way to create one yet.
Flags: in-testsuite- → in-testsuite?
Comment 10•19 years ago
|
||
Re-landed:
mozilla/netwerk/base/src/nsURLParsers.cpp 1.29
Sorry I didn't try to fix the bustage the last time - didn't really have time to experiment on the tinderbox :)
Status: REOPENED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: mozilla1.9alpha4 → mozilla1.9alpha5
You need to log in
before you can comment on or make changes to this bug.
Description
•