mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 493495. Protect against recursive attempts to report a security exception in cases when the URI objects involved can't be accessed due to being implemented as a JS component. r+sr=mrbkap
This commit is contained in:
parent
c250d485f0
commit
9f358b989d
@ -126,11 +126,24 @@ JSValIDToString(JSContext *cx, const jsval idval)
|
||||
return reinterpret_cast<PRUnichar*>(JS_GetStringChars(str));
|
||||
}
|
||||
|
||||
class nsAutoInPrincipalDomainOriginSetter {
|
||||
public:
|
||||
nsAutoInPrincipalDomainOriginSetter() {
|
||||
++sInPrincipalDomainOrigin;
|
||||
}
|
||||
~nsAutoInPrincipalDomainOriginSetter() {
|
||||
--sInPrincipalDomainOrigin;
|
||||
}
|
||||
static PRUint32 sInPrincipalDomainOrigin;
|
||||
};
|
||||
PRUint32 nsAutoInPrincipalDomainOriginSetter::sInPrincipalDomainOrigin;
|
||||
|
||||
static
|
||||
nsresult
|
||||
GetPrincipalDomainOrigin(nsIPrincipal* aPrincipal,
|
||||
nsACString& aOrigin)
|
||||
{
|
||||
nsAutoInPrincipalDomainOriginSetter autoSetter;
|
||||
aOrigin.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
@ -811,11 +824,16 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
||||
|
||||
NS_ConvertUTF8toUTF16 className(classInfoData.GetName());
|
||||
nsCAutoString subjectOrigin;
|
||||
if (!nsAutoInPrincipalDomainOriginSetter::sInPrincipalDomainOrigin) {
|
||||
GetPrincipalDomainOrigin(subjectPrincipal, subjectOrigin);
|
||||
} else {
|
||||
subjectOrigin.AssignLiteral("the security manager");
|
||||
}
|
||||
NS_ConvertUTF8toUTF16 subjectOriginUnicode(subjectOrigin);
|
||||
|
||||
nsCAutoString objectOrigin;
|
||||
if (objectPrincipal) {
|
||||
if (!nsAutoInPrincipalDomainOriginSetter::sInPrincipalDomainOrigin &&
|
||||
objectPrincipal) {
|
||||
GetPrincipalDomainOrigin(objectPrincipal, objectOrigin);
|
||||
}
|
||||
NS_ConvertUTF8toUTF16 objectOriginUnicode(objectOrigin);
|
||||
@ -831,7 +849,8 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
||||
|
||||
PRUint32 length = NS_ARRAY_LENGTH(formatStrings);
|
||||
|
||||
if (!objectPrincipal) {
|
||||
if (nsAutoInPrincipalDomainOriginSetter::sInPrincipalDomainOrigin ||
|
||||
!objectPrincipal) {
|
||||
stringName.AppendLiteral("OnlySubject");
|
||||
--length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user