Address misc issues with nsICMSMessage2.idl
Categories
(MailNews Core :: Security: S/MIME, defect)
Tracking
(Not tracked)
People
(Reporter: KaiE, Assigned: benc)
References
Details
Attachments
(1 file, 1 obsolete file)
21.64 KB,
patch
|
KaiE
:
review+
|
Details | Diff | Splinter Review |
Comment 1•19 years ago
|
||
Updated•18 years ago
|
Reporter | ||
Comment 2•13 years ago
|
||
![]() |
||
Comment 3•9 years ago
|
||
![]() |
||
Updated•9 years ago
|
Comment 4•6 years ago
|
||
Noticed this looking at bug 1551704. Ben, maybe we can get rid of this "array" too.
Assignee | ||
Comment 5•6 years ago
|
||
Mostly simple, but a few little cleanups, mainly to the error handling. The error handling ones could do with a second opinion. eg:
- there was a place where PR_GetError() was used instead of checking the nsresult to a XPCOM call.
- there was a call to nsIOutputStream::write() where I removed the check on the number of bytes written, on the grounds that a truncated write is an error anyway (nsIOutputstream doesn't seem explicit about this, but the PR_Write that underlies a lot of outputstream implementations is).
try build looks sane:
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=37a45a3b79d56509f3a20dac4f5b8ca13512fafa
Updated•6 years ago
|
Updated•6 years ago
|
Reporter | ||
Comment 6•6 years ago
•
|
||
Wow. Thanks for getting to that very old bug that I've filed 14 years ago.
The patch looks mostly good, except the two places that you've pointed out.
(In reply to Ben Campbell from comment #5)
Mostly simple, but a few little cleanups, mainly to the error handling. The error handling ones could do with a second opinion. eg:
- there was a place where PR_GetError() was used instead of checking the nsresult to a XPCOM call.
The related underlying NSS API calls are HASH_Begin, HASH_Update and HASH_End, all of them have return type void, and nsCryptoHash doesn't check for PR_GetError(), so potentially it might be necessary.
We should investigate, I've filed bug 1609449.
- there was a call to nsIOutputStream::write() where I removed the check on the number of bytes written, on the grounds that a truncated write is an error anyway (nsIOutputstream doesn't seem explicit about this, but the PR_Write that underlies a lot of outputstream implementations is).
The API description explicitly allows a partial write:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/xpcom/io/nsIOutputStream.idl#78
If the current implementation cannot handle a partial write, then we should keep the current check for the number of bytes written.
The place you've changed (and several other unchanged places in that file) all return a special value of -1, casting to nsresult. I don't know if that special result value is consumed and expected by any callers. Maybe we should keep this result code, until we've been able to verify that no callers (up the caller chain) expect a -1 on failure.
The try build might not be a good way to answer that question, we don't have much test coverage for S/MIME processing failures.
Reporter | ||
Comment 7•6 years ago
|
||
If you keep the existing check for PR_GetError, and keep returning that failure on a short write, I can give you r+ immediately.
If you want to clean up those details, we could have a follow-up bug. If you file one, it should suggest that all uses of MK_MIME_ERROR_WRITING_FILE to be replaced (after code investigation).
Assignee | ||
Comment 8•6 years ago
|
||
Thanks Kai - exactly the second opinion I was looking for!
Updated patch, with restored PR_GetError() and partial-write check.
With the PR_GetError() case I did add some code to set a failing nsresult if there was an error (previously I think a PR error would have caused and early exit returning NS_OK).
Forgot to mention it earlier, but I removed the goto FAIL
s just because they didn't like me adding the a new digest
local mid-scope. Nothing particularly ideological, but there was no cleanup code, so seemed cleanest to just bail out immediately.
(I've reset the r?, but the only changes are in mailnews/extensions/smime/src/nsMsgComposeSecure.cpp).
Assignee | ||
Comment 9•6 years ago
•
|
||
(In reply to Kai Engert (:KaiE:) from comment #6)
The API description explicitly allows a partial write:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/xpcom/io/nsIOutputStream.idl#78
Huh. My initial reading of that made it seem more ambiguous. But yeah, it seems pretty clear that non-error truncated writes should be expected.
If the current implementation cannot handle a partial write, then we should keep the current check for the number of bytes written.
Should we instead be looping around counting bytes until they've all been sent (or an error occurs)?
In what circumstances should truncated writes be expected? I'm guessing some network-based stream implementations...
(there are about 7 uses of Write() in nsMsgComposeSecure, and the looping code isn't any bigger than the existing truncated-write check. But I'd be willing to bet that there are a whole heap of other such cases to check in c-c... is this worth addressing?)
The place you've changed (and several other unchanged places in that file) all return a special value of -1, casting to nsresult. I don't know if that special result value is consumed and expected by any callers. Maybe we should keep this result code, until we've been able to verify that no callers (up the caller chain) expect a -1 on failure.
Written up in Bug 1609549.
Reporter | ||
Comment 10•6 years ago
|
||
(In reply to Ben Campbell from comment #9)
Should we instead be looping around counting bytes until they've all been sent (or an error occurs)?
In what circumstances should truncated writes be expected? I'm guessing some network-based stream implementations...
(there are about 7 uses of Write() in nsMsgComposeSecure, and the looping code isn't any bigger than the existing truncated-write check. But I'd be willing to bet that there are a whole heap of other such cases to check in c-c... is this worth addressing?)
Difficult to say if looping is safe. I'd be reluctant to touch this without a good understanding of the consequences, given our priorities might not allow us to to spend much time on S/MIME.
Reporter | ||
Comment 11•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Comment 12•6 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/bbea4c75d982
Use Array<octet> for passing byte buffers in nsICMSMessage.idl. r=kaie
Updated•6 years ago
|
Description
•