Closed Bug 14820 Opened 25 years ago Closed 25 years ago

Fixing up the relationship between nsCodeBasePrincipal and nsJSPrincipals

Categories

(Core :: Security: CAPS, defect, P3)

All
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: mscott, Assigned: norrisboyd)

Details

This came out of an IRC discussion with brendan about Bug #14815 about how to
properly fix the relationship between nsCodeBasePrincipal and nsJSPrincipals.

Rather than re-summarize the discussion, I'm going to save my wrists and just
dump part of the irc session:

<brendan2> the idea is this: JSPrincipals (part of a C api) has a ref_count
member, non-XPCOM refcounting
<brendan2> so instead of NS_IMPL_ISUPPORTS in impls that embed a struct member
JSPrincipals
<brendan2> write custom addref/release that use the embedded JSPrincipals
struct's ref_count member
<brendan2> if this is more than you wanted to know, i'll just update the bug
<mscott> hang on i'm looking back at the code
<brendan2> see, that weak ref must be weak because nsJSPrincipals is a struct
that must be embedded
<mscott> JSPrincipals has the ref cnt variable it just doesn't appear to be
used?
<brendan2> it'd be better if there were only one ref_count for any ns*Principal
impl that embedded JSPrincipals
<mscott> i'm with you
<mscott> so the codebase principal needs to addref the struct's refcnt variable
instead of using the XPCOM versions?
<brendan2> the ns*Principal (note singular, not Principals) impls could all have
custom AddRef methods that call JSPRINCIPALS_HOLD, and Release methods that call
 JSPRINCIPALS_DROP
<brendan2> could share these (one AddRef/Release pair among all ns*Principal
Impls)
<brendan2> JSPrincipals.destroy knows how to downcast JSPrincipals* to
nsJSPrincipals*, then gets weak ref to ns*Principal and deletes the impl
<brendan2> one goal here is to fuse allocations, avoid yet another malloc
<brendan2> another is to fuse refcounts
<brendan2> arielb met first goal, not second, left bugs
Status: NEW → ASSIGNED
Target Milestone: M11
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
QA: code change: no verification needed.

We now have a common refcount.
Component: CAPS → Security: CAPS
Moving all CAPS bugs to Security: CAPS component.  CAPS component will be 
deleted.
Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.