Closed Bug 88230 Opened 24 years ago Closed 24 years ago

nsNSSComponent will crash is called when unitialized

Categories

(Core Graveyard :: Security: UI, defect, P1)

1.0 Branch
defect

Tracking

(Not tracked)

VERIFIED FIXED
psm2.1

People

(Reporter: ccarlen, Assigned: javi)

References

Details

Attachments

(3 files)

I came across this in working on bug 86021 . It uses profile switching, to which the NSSComponent listens, to do the job. Problem is, the profile mgr window needs to be brought up after NSS has been shut down but before is has been restarted. See http://lxr.mozilla.org/mozilla/source/security/manager/ssl/src/nsNSSComponent.cpp#746 . During this time at which it's unitialized, mouse movement will cause RandomUpdate to be called and kaboom. So, the simple patch here checks the state of mNSSInitilized before calling it. Then I noticed something really odd: that flag is only set after a profile change but never in the normal couse of things. Notice how in the destructor, it checks that flag before calling NSS_Shutdown.
This bit: + nsCOMPtr<nsIObserverService> observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); has nothing to do with the problem reported here. I just noticed that the method was returning an uninitialized rv :-/
Updating version and adding to cc list.
Target Milestone: --- → 2.1
Version: 1.01 → 2.0
Blocks: 86021
I'd rather move this block: - + + mNSSInitialized = PR_TRUE; to the end of the method. That way it will only be set if all initialization succeeded. Other than that, patch looks good.
Javi - I wasn't sure about that myself. Say it fails and we don't set the flag so we then try again - is that safe?
If we set the flag at the beginning and fail, then the very next time we try to initialize NSS the very first check in the method will cause an error and that means NSS will never be initialized. But after looking at the code, it seems that we just waltz through, so the patch will work for now, but if we ever (ahem) add error checking past that point, then we could run into problems. Bottom line, today that won't cause a problem, but if we modify the code one day to do more error checking, then we run the risk of missing the fact that we'd have to move the initialization of mNSSInitialized.
Keywords: nsenterprise
Priority: -- → P1
Thanks, Javi. Problem is, I can't check this one because it's not part of SeaMonkeyAll. Can you do this?
sr=tor
Patch checked in.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified per javi's comment.
Status: RESOLVED → VERIFIED
Product: PSM → Core
Version: psm2.0 → 1.0 Branch
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: