Closed Bug 128215 Opened 23 years ago Closed 22 years ago

nsIScriptableInputStream can not handle embedded \0 characters.

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 170585
Future

People

(Reporter: markh, Assigned: dougt)

Details

(Keywords: helpwanted)

Came up on IRC.

nsIScriptableInputStream defines read as:

    string read(in unsigned long aCount); 

This does not handle embedded \0 characters.

The "correct" fix is probably to use a byte array, but this makes usage from 
javascript a pain for the common case, and would be a nightmare to fix all the 
old code.

Therefore I propose a new:
void readBinary(in unsigned long aCount, out PRUint32 outCount, [retval, array, 
size_is(outCount)] out PRUint8 data); 

Then anyone who cares about binary data can go through the pain of that extra 
param and array management.  (Of course, PyXPCOM handles all that magically, so 
would look like a normal read, but that isn't really relevant ;-)

I'm happy to make a patch is there is agreement.
Can we use the new ACString stuff?  jag?

void read(in unsigned long aCount, [retval] out ACString buf);
darin?
hmm... brendan said that an octet array would be best, but that it would also be
slow until JS2 comes along.  cc'ing nisheeth since he did the xpconnect work... 
i wonder how xpconnect treats embedded nulls.
speaking to jag about this...  he will update this bug soon...
Sure, |ACString| should be fine, as long as the supplying end provides a ptr +
length. If only given a ptr, we'll do a \0 search.
Shaver: why the retval fu though?

  ACString read(in unsigned long aCount);

should work just fine.
That would be too clear!  Ahem.

The [retval] foo came from a string-with-size attempt that predated my ACString
suggestion in my mind, if not in the bug.  Thanks for the clue.
Feel free to reassign or to move tm back with a working patch.  :-)
Keywords: helpwanted
Target Milestone: --- → mozilla1.2
Target Milestone: mozilla1.2alpha → Future

*** This bug has been marked as a duplicate of 170585 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.