зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
da23ed12a5
Коммит
32f8ab9ba2
|
@ -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;
|
||||
GetPrincipalDomainOrigin(subjectPrincipal, 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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче