Closed Bug 435587 Opened 16 years ago Closed 16 years ago

Crash [@ nsMsgCompose::ProcessSignature] when htmlSigText is set but no signature file is given

Categories

(MailNews Core :: Composition, defect)

defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9

People

(Reporter: rsx11m.pub, Assigned: rsx11m.pub)

References

Details

(Keywords: crash)

Crash Data

Attachments

(1 file, 3 obsolete files)

While testing for bug 428040, this scenario would crash on current trunk: Set the htmlSigText preference for an identity with a valid signature string, but leave "Attach this signature:" unchecked, then compose a new message.

The apparent reason is that the handling of the recently introduced preference "mail.identity.id*.htmlSigText" allows code accessing the signature file to be executed where it would not before. That code relies on the presence of the file, thus additional conditions have to be introduced to cover those cases.
Attached patch Quick fix (obsolete) — Splinter Review
This patch initializes PRBool exists correctly and adds further checks on "exists" before executing code processing the signature file.
Attachment #322383 - Flags: superreview?(neil)
Attachment #322383 - Flags: review?(philringnalda)
Comment on attachment 322383 [details] [diff] [review]
Quick fix

I can't seem to find the bug where this code was added :-( I wonder whether the exists check should occur before checking the mime type.
Attachment #322383 - Flags: superreview?(neil) → superreview+
Neil: According to bonsai, the htmlSigText pref was introduced with revisions 1.504-1.507 by bug 33451, attachment 260305 [details] [diff] [review]. This bug has a rather large
collection of patches, but I couldn't find any comment on this specific pref.
The checking of the MIME type before the existence check was introduced by
bug 225570, revision 1.412-1.413 of nsMsgCompose.cpp.

Anyway, even if GetTypeFromFile() catches the non-existing filename case, it's certainly cleaner to test this upfront. Also, the "exists" variable appears redundant as a global variable and can be combined with "useSigFile".
Informational. The "exists" variable is now a local variable and "useSigFile" will not be set PR_TRUE if the file doesn't exists. Also, the MIME-type check won't be executed either in this case. All following checks are consolidated, using "useSigFile" only, to simplify the code.
Attached patch Better fix (v2) (obsolete) — Splinter Review
Patch from attachment 322533 [details] [diff] [review] after adjustment of white spaces.
Carrying forward sr+ from attachment 322383 [details] [diff] [review].
Attachment #322383 - Attachment is obsolete: true
Attachment #322534 - Flags: superreview+
Attachment #322534 - Flags: review?(philringnalda)
Attachment #322383 - Flags: review?(philringnalda)
Comment on attachment 322533 [details] [diff] [review]
Better fix (v2, before white-space adjustment)

>diff -u -8 -p -r1.561 nsMsgCompose.cpp
Normally when creating a patch that involves significant whitespace changes (as here) it's best to write the final patch but create a second diff including -w.

>-  if (imageSig)
>+  if (useSigFile && imageSig)
I think your new code ensures that imageSig is only set after useSigFile is.
Attached patch Better fix (v3)Splinter Review
(In reply to comment #6)
> I think your new code ensures that imageSig is only set after useSigFile is.

Oops, I've missed that. Since imageSig is initialized PR_FALSE, it can't be true unless useSigFile applies and we checked the MIME type. Thanks.
Assignee: nobody → rsx11m.pub
Attachment #322534 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #322569 - Flags: superreview+
Attachment #322569 - Flags: review?(philringnalda)
Attachment #322534 - Flags: review?(philringnalda)
Comment on attachment 322569 [details] [diff] [review]
Better fix (v3)

Sorry, I can only review in mail/, for mailnews/ you want someone from http://www.mozilla.org/owners.html#mail-and-news-backend
Attachment #322569 - Flags: review?(philringnalda)
Severity: normal → critical
Summary: Crash [nsMsgCompose::ProcessSignature] when htmlSigText is set but no signature file given → Crash [@ nsMsgCompose::ProcessSignature] when htmlSigText is set but no signature file is given
Attachment #322569 - Flags: review?(bugzilla)
Attachment #322569 - Flags: review?(bugzilla) → review+
Thanks Mark, checkin for trunk please.
Keywords: checkin-needed
Attachment #322533 - Attachment is obsolete: true
Checking in mailnews/compose/src/nsMsgCompose.cpp;
/cvsroot/mozilla/mailnews/compose/src/nsMsgCompose.cpp,v  <--  nsMsgCompose.cpp
new revision: 1.562; previous revision: 1.561
done
Keywords: checkin-needed
-> FIXED
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9
Product: Core → MailNews Core
Crash Signature: [@ nsMsgCompose::ProcessSignature]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: