Access privileges to methods should be done in OP_MEMBER.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-05-23 08:27:56 +02:00
parent e654e42b07
commit 5cc4a5e48d
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
1 changed files with 3 additions and 21 deletions

View File

@ -4154,7 +4154,7 @@ static sxi32 VmByteCodeExec(
pThis = (ph7_class_instance *)pNos->x.pOther; pThis = (ph7_class_instance *)pNos->x.pOther;
/* Point to the instantiated class */ /* Point to the instantiated class */
pClass = pThis->pClass; pClass = pThis->pClass;
if(pNos->iFlags == MEMOBJ_PARENTOBJ) { if(pNos->iFlags == MEMOBJ_BASEOBJ || pNos->iFlags == MEMOBJ_PARENTOBJ) {
if(pClass->pBase == 0) { if(pClass->pBase == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Attempt to call parent class from non-inheritance instance of class '%z'", &pClass->sName); "Attempt to call parent class from non-inheritance instance of class '%z'", &pClass->sName);
@ -4572,15 +4572,7 @@ static sxi32 VmByteCodeExec(
pThis = (ph7_class_instance *)pTarget->x.pOther; pThis = (ph7_class_instance *)pTarget->x.pOther;
pThis->iRef += 3; pThis->iRef += 3;
pClass = pThis->pClass; pClass = pThis->pClass;
if(pTarget->iFlags == MEMOBJ_PARENTOBJ) { pThis->pClass = pVmFunc->pClass;
/* Parent called */
if(pThis->pClass->pBase == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Attempt to call parent class from non-inheritance instance of class '%z'", &pClass->sName);
}
/* Swap to parent class */
pThis->pClass = pThis->pClass->pBase;
}
pSelf = pThis->pClass; pSelf = pThis->pClass;
} }
if(pSelf == 0) { if(pSelf == 0) {
@ -4605,16 +4597,6 @@ static sxi32 VmByteCodeExec(
while(pArg < pStack) { while(pArg < pStack) {
pArg++; pArg++;
} }
if(pSelf) { /* Paranoid edition */
/* Check if the call is allowed */
pMeth = PH7_ClassExtractMethod(pSelf, pVmFunc->sName.zString, pVmFunc->sName.nByte);
if(pMeth && pMeth->iProtection != PH7_CLASS_PROT_PUBLIC) {
if(!VmClassMemberAccess(&(*pVm), pSelf, &pVmFunc->sName, pMeth->iProtection, FALSE)) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Access to the class method '%z->%z()' is forbidden", &pSelf->sName, &pVmFunc->sName);
}
}
}
} }
} }
/* Check The recursion limit */ /* Check The recursion limit */
@ -4946,7 +4928,7 @@ static sxi32 VmByteCodeExec(
SyMemBackendFree(&pVm->sAllocator, pFrameStack); SyMemBackendFree(&pVm->sAllocator, pFrameStack);
/* Leave the frame */ /* Leave the frame */
VmLeaveFrame(&(*pVm)); VmLeaveFrame(&(*pVm));
if(pClass != 0) { if(pClass != 0 && pClass != pThis->pClass) {
/* Restore original class */ /* Restore original class */
pThis->pClass = pClass; pThis->pClass = pClass;
} }