Closed Bug 239405 Opened 20 years ago Closed 20 years ago

strchr, strrchr, etc. implicit const_cast can cause problems for shared string buffers

Categories

(Core :: XPCOM, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.7final

People

(Reporter: darin.moz, Assigned: darin.moz)

Details

Attachments

(1 file)

strchr, strrchr, etc. implicit const_cast can cause problems for shared string
buffers.

see bug 239226.  we need to do some careful grepping of the tree to catch these
kinds of problems.
Status: NEW → ASSIGNED
Flags: blocking1.7?
Priority: -- → P1
Target Milestone: --- → mozilla1.7final
got about a dozen or so hits... attaching patch...
Attached patch v1 patchSplinter Review
Attachment #145317 - Flags: superreview?(dbaron)
Attachment #145317 - Flags: review?(bienvenu)
>     // move past "data:"
>-    const char *buffer = strstr(spec.get(), "data:");
>+    const char *buffer = strstr(spec.BeginWriting(), "data:");
>     if (!buffer) {
>         // malfored url
>         return NS_ERROR_MALFORMED_URI;
>     }
>     buffer += 5;
> 
>     // First, find the start of the data
>     char *comma = PL_strchr(buffer, ',');
Shouldn't buffer have its constness removed too, for consistency?
neil: yeah, good point.  i'll make that change.
Attachment #145317 - Flags: review?(bienvenu) → review+
Comment on attachment 145317 [details] [diff] [review]
v1 patch

sr=dbaron given comment 3
Attachment #145317 - Flags: superreview?(dbaron) → superreview+
Attachment #145317 - Flags: approval1.7?
Comment on attachment 145317 [details] [diff] [review]
v1 patch

a=chofmann for 1.7
Attachment #145317 - Flags: approval1.7? → approval1.7+
fixed-on-trunk for 1.7 final
.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Flags: blocking1.7?
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: