Closed
Bug 141866
Opened 23 years ago
Closed 23 years ago
NS_ConvertUTF8toUCS2(ptr, length) doesn't correctly handle given length
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: mikepinkerton, Assigned: jag+mozilla)
References
Details
(Keywords: topembed+)
Attachments
(1 file)
586 bytes,
patch
|
mikepinkerton
:
review+
scc
:
superreview+
jesup
:
approval+
|
Details | Diff | Splinter Review |
in trying to use
NS_ConvertUTF8toUCS2( const char* aCString, PRUint32 aLength )
{
Init( nsDependentCString( aCString, aLength ) );
}
I discovered that even if aCString is null terminated, nsDependentCString will
assert in Rebind if the null comes after |aLength| bytes.
this blocks work in 69566
Reporter | ||
Comment 1•23 years ago
|
||
topembed because it blocks a topembed bug
Blocks: 69566
Keywords: mozilla1.0,
topembed
Assignee | ||
Comment 2•23 years ago
|
||
The problem isn't with nsDependentCString, that does exactly what it should.
The problem is that we didn't allow a substring of the |const char*| to be
passed in.
Comment 3•23 years ago
|
||
Comment on attachment 82131 [details] [diff] [review]
Make NS_ConvertUTF8toUCS2(ptr, length) work with substrings
sr=scc, and thanks for the fix, jag
Attachment #82131 -
Flags: superreview+
Assignee | ||
Comment 4•23 years ago
|
||
Updating summary.
Summary: nsDependentCString doesn't correctly handle given length when looking for null termination → NS_ConvertUTF8toUCS2(ptr, length) doesn't correctly handle given length
Reporter | ||
Comment 6•23 years ago
|
||
Comment on attachment 82131 [details] [diff] [review]
Make NS_ConvertUTF8toUCS2(ptr, length) work with substrings
r=pink.
i'm going to land this.
Attachment #82131 -
Flags: review+
Reporter | ||
Comment 7•23 years ago
|
||
landed on trunk. we need this on the branch for 69566
Reporter | ||
Comment 8•23 years ago
|
||
actually, this patch doesn't work.
Reporter | ||
Comment 9•23 years ago
|
||
removing adt keyword. it appears we were premature. the patch doesn't work.
also, don't a whole bunch of other things that use nsDependent*String(foo, len)
have to be changed as well?
Keywords: adt1.0.0
Other things that use nsDependent[C]String(str,len) should already have been
fixed. The patch certainly should fix the assertion, and seems like the right
thing to do. What doesn't work about it? (nsDependentCString is an
nsAFlatCString, which implies that the buffer is null-terminated at its length.
|Substring| returns an object that is an nsASingleFragmentCString (one higher
in the hierarchy), which doesn't imply null-termination.)
(That is, they should have been fixed if the |len| that they were providing was
there to indicate that a substring was desired rather than that the length of
the string was already known.)
Reporter | ||
Comment 12•23 years ago
|
||
i'm still getting the assert about it having to be null terminated, even with
the change, but then again the dependency checking in the win32 gmake build is
so bad, it might be a phantom. i'm doing a full rebuild now just to be certain.
Reporter | ||
Comment 13•23 years ago
|
||
did a full rebuild, it still asserts, but now with a different assert.
if i don't give it a length, it's ok. if i do give it a length, it asserts now
that this can only be used with a known UTF8 string (which it is). What's the
difference?
What's the stack for the new assertion? And what's the input string?
Assignee | ||
Comment 15•23 years ago
|
||
Hmmm... That sounds like your buffer contains a character it can't decode.
Assignee | ||
Comment 16•23 years ago
|
||
If you don't give NS_ConvertUTF8toUCS2 a length, it'll go find the zero
terminator and determine the length of the buffer that way. It's the equivalent
of doing |NS_ConvertUTF8toUCS2(str, strlen(str))|.
So, since it can decode the utf8 buffer just fine if you don't give it a length,
it sounds like you're cutting some utf8 char in half (or whatever) with the
length you've given.
Reporter | ||
Comment 17•23 years ago
|
||
hrm, this is just a simple ascii string, all characters are in the range 00 ->
7F. i dont see any multi-byte characters anywhere in my string.
So what's the stack for the new assertion? We're only guessing at which
assertion you might have hit.
Reporter | ||
Comment 19•23 years ago
|
||
landed. we need this on the branch for embedding (for 69566)
Keywords: adt1.0.0
Comment 20•23 years ago
|
||
adding adt1.0.0+. Please get drivers approval before checking into the 1.0 branch.
Comment 21•23 years ago
|
||
Comment on attachment 82131 [details] [diff] [review]
Make NS_ConvertUTF8toUCS2(ptr, length) work with substrings
a=rjesup@wgate.com (make sure it's in trunk too)
Attachment #82131 -
Flags: approval+
Reporter | ||
Comment 22•23 years ago
|
||
landed on 1.0.0 branch on 5/16/02
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Reporter | ||
Updated•23 years ago
|
Keywords: adt1.0.0+ → fixed1.0.0
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•