Enable the magic number protection.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
3dcc908788
commit
48d5088265
|
@ -189,11 +189,9 @@ static sxi32 PH7CoreConfigure(sxi32 nOp, va_list ap) {
|
||||||
case PH7_LIB_CONFIG_USER_MUTEX: {
|
case PH7_LIB_CONFIG_USER_MUTEX: {
|
||||||
/* Use an alternative low-level mutex subsystem */
|
/* Use an alternative low-level mutex subsystem */
|
||||||
const SyMutexMethods *pMethods = va_arg(ap, const SyMutexMethods *);
|
const SyMutexMethods *pMethods = va_arg(ap, const SyMutexMethods *);
|
||||||
#if defined (UNTRUST)
|
|
||||||
if(pMethods == 0) {
|
if(pMethods == 0) {
|
||||||
rc = PH7_CORRUPT;
|
rc = PH7_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if(pMethods->xEnter == 0 || pMethods->xLeave == 0 || pMethods->xNew == 0) {
|
if(pMethods->xEnter == 0 || pMethods->xLeave == 0 || pMethods->xNew == 0) {
|
||||||
/* At least three criticial callbacks xEnter(),xLeave() and xNew() must be supplied */
|
/* At least three criticial callbacks xEnter(),xLeave() and xNew() must be supplied */
|
||||||
|
@ -490,11 +488,9 @@ int ph7_config(ph7 *pEngine, int nConfigOp, ...) {
|
||||||
int ph7_init(ph7 **ppEngine) {
|
int ph7_init(ph7 **ppEngine) {
|
||||||
ph7 *pEngine;
|
ph7 *pEngine;
|
||||||
int rc;
|
int rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(ppEngine == 0) {
|
if(ppEngine == 0) {
|
||||||
return PH7_CORRUPT;
|
return PH7_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*ppEngine = 0;
|
*ppEngine = 0;
|
||||||
/* One-time automatic library initialization */
|
/* One-time automatic library initialization */
|
||||||
rc = PH7CoreInitialize();
|
rc = PH7CoreInitialize();
|
||||||
|
@ -770,11 +766,9 @@ int ph7_vm_dump(ph7_vm *pVm, int (*xConsumer)(const void *, unsigned int, void *
|
||||||
if(PH7_VM_MISUSE(pVm)) {
|
if(PH7_VM_MISUSE(pVm)) {
|
||||||
return PH7_CORRUPT;
|
return PH7_CORRUPT;
|
||||||
}
|
}
|
||||||
#ifdef UNTRUST
|
|
||||||
if(xConsumer == 0) {
|
if(xConsumer == 0) {
|
||||||
return PH7_CORRUPT;
|
return PH7_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Dump VM instructions */
|
/* Dump VM instructions */
|
||||||
rc = PH7_VmDump(&(*pVm), xConsumer, pUserData);
|
rc = PH7_VmDump(&(*pVm), xConsumer, pUserData);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -145,11 +145,9 @@ struct SyHashEntry_Pr {
|
||||||
sxu32 SyBinHash(const void *pSrc, sxu32 nLen);
|
sxu32 SyBinHash(const void *pSrc, sxu32 nLen);
|
||||||
PH7_PRIVATE sxi32 SyHashInit(SyHash *pHash, SyMemBackend *pAllocator, ProcHash xHash, ProcCmp xCmp) {
|
PH7_PRIVATE sxi32 SyHashInit(SyHash *pHash, SyMemBackend *pAllocator, ProcHash xHash, ProcCmp xCmp) {
|
||||||
SyHashEntry_Pr **apNew;
|
SyHashEntry_Pr **apNew;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pHash == 0) {
|
if(pHash == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Allocate a new table */
|
/* Allocate a new table */
|
||||||
apNew = (SyHashEntry_Pr **)SyMemBackendAlloc(&(*pAllocator), sizeof(SyHashEntry_Pr *) * SXHASH_BUCKET_SIZE);
|
apNew = (SyHashEntry_Pr **)SyMemBackendAlloc(&(*pAllocator), sizeof(SyHashEntry_Pr *) * SXHASH_BUCKET_SIZE);
|
||||||
if(apNew == 0) {
|
if(apNew == 0) {
|
||||||
|
@ -167,11 +165,9 @@ PH7_PRIVATE sxi32 SyHashInit(SyHash *pHash, SyMemBackend *pAllocator, ProcHash x
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyHashRelease(SyHash *pHash) {
|
PH7_PRIVATE sxi32 SyHashRelease(SyHash *pHash) {
|
||||||
SyHashEntry_Pr *pEntry, *pNext;
|
SyHashEntry_Pr *pEntry, *pNext;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pEntry = pHash->pList;
|
pEntry = pHash->pList;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(pHash->nEntry == 0) {
|
if(pHash->nEntry == 0) {
|
||||||
|
@ -210,11 +206,9 @@ static SyHashEntry_Pr *HashGetEntry(SyHash *pHash, const void *pKey, sxu32 nKeyL
|
||||||
}
|
}
|
||||||
PH7_PRIVATE SyHashEntry *SyHashGet(SyHash *pHash, const void *pKey, sxu32 nKeyLen) {
|
PH7_PRIVATE SyHashEntry *SyHashGet(SyHash *pHash, const void *pKey, sxu32 nKeyLen) {
|
||||||
SyHashEntry_Pr *pEntry;
|
SyHashEntry_Pr *pEntry;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pHash->nEntry < 1 || nKeyLen < 1) {
|
if(pHash->nEntry < 1 || nKeyLen < 1) {
|
||||||
/* Don't bother hashing,return immediately */
|
/* Don't bother hashing,return immediately */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -248,11 +242,9 @@ static sxi32 HashDeleteEntry(SyHash *pHash, SyHashEntry_Pr *pEntry, void **ppUse
|
||||||
PH7_PRIVATE sxi32 SyHashDeleteEntry(SyHash *pHash, const void *pKey, sxu32 nKeyLen, void **ppUserData) {
|
PH7_PRIVATE sxi32 SyHashDeleteEntry(SyHash *pHash, const void *pKey, sxu32 nKeyLen, void **ppUserData) {
|
||||||
SyHashEntry_Pr *pEntry;
|
SyHashEntry_Pr *pEntry;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pEntry = HashGetEntry(&(*pHash), pKey, nKeyLen);
|
pEntry = HashGetEntry(&(*pHash), pKey, nKeyLen);
|
||||||
if(pEntry == 0) {
|
if(pEntry == 0) {
|
||||||
return SXERR_NOTFOUND;
|
return SXERR_NOTFOUND;
|
||||||
|
@ -263,30 +255,24 @@ PH7_PRIVATE sxi32 SyHashDeleteEntry(SyHash *pHash, const void *pKey, sxu32 nKeyL
|
||||||
PH7_PRIVATE sxi32 SyHashDeleteEntry2(SyHashEntry *pEntry) {
|
PH7_PRIVATE sxi32 SyHashDeleteEntry2(SyHashEntry *pEntry) {
|
||||||
SyHashEntry_Pr *pPtr = (SyHashEntry_Pr *)pEntry;
|
SyHashEntry_Pr *pPtr = (SyHashEntry_Pr *)pEntry;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pPtr == 0 || INVALID_HASH(pPtr->pHash)) {
|
if(pPtr == 0 || INVALID_HASH(pPtr->pHash)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = HashDeleteEntry(pPtr->pHash, pPtr, 0);
|
rc = HashDeleteEntry(pPtr->pHash, pPtr, 0);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyHashResetLoopCursor(SyHash *pHash) {
|
PH7_PRIVATE sxi32 SyHashResetLoopCursor(SyHash *pHash) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pHash->pCurrent = pHash->pList;
|
pHash->pCurrent = pHash->pList;
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE SyHashEntry *SyHashGetNextEntry(SyHash *pHash) {
|
PH7_PRIVATE SyHashEntry *SyHashGetNextEntry(SyHash *pHash) {
|
||||||
SyHashEntry_Pr *pEntry;
|
SyHashEntry_Pr *pEntry;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pHash->pCurrent == 0 || pHash->nEntry <= 0) {
|
if(pHash->pCurrent == 0 || pHash->nEntry <= 0) {
|
||||||
pHash->pCurrent = pHash->pList;
|
pHash->pCurrent = pHash->pList;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -301,11 +287,9 @@ PH7_PRIVATE sxi32 SyHashForEach(SyHash *pHash, sxi32(*xStep)(SyHashEntry *, void
|
||||||
SyHashEntry_Pr *pEntry;
|
SyHashEntry_Pr *pEntry;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash) || xStep == 0) {
|
if(INVALID_HASH(pHash) || xStep == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pEntry = pHash->pList;
|
pEntry = pHash->pList;
|
||||||
for(n = 0 ; n < pHash->nEntry ; n++) {
|
for(n = 0 ; n < pHash->nEntry ; n++) {
|
||||||
/* Invoke the callback */
|
/* Invoke the callback */
|
||||||
|
@ -369,11 +353,9 @@ static sxi32 HashInsert(SyHash *pHash, SyHashEntry_Pr *pEntry) {
|
||||||
PH7_PRIVATE sxi32 SyHashInsert(SyHash *pHash, const void *pKey, sxu32 nKeyLen, void *pUserData) {
|
PH7_PRIVATE sxi32 SyHashInsert(SyHash *pHash, const void *pKey, sxu32 nKeyLen, void *pUserData) {
|
||||||
SyHashEntry_Pr *pEntry;
|
SyHashEntry_Pr *pEntry;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash) || pKey == 0) {
|
if(INVALID_HASH(pHash) || pKey == 0) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pHash->nEntry >= pHash->nBucketSize * SXHASH_FILL_FACTOR) {
|
if(pHash->nEntry >= pHash->nBucketSize * SXHASH_FILL_FACTOR) {
|
||||||
rc = HashGrowTable(&(*pHash));
|
rc = HashGrowTable(&(*pHash));
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
|
@ -397,11 +379,9 @@ PH7_PRIVATE sxi32 SyHashInsert(SyHash *pHash, const void *pKey, sxu32 nKeyLen, v
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE SyHashEntry *SyHashLastEntry(SyHash *pHash) {
|
PH7_PRIVATE SyHashEntry *SyHashLastEntry(SyHash *pHash) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(INVALID_HASH(pHash)) {
|
if(INVALID_HASH(pHash)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Last inserted entry */
|
/* Last inserted entry */
|
||||||
return (SyHashEntry *)pHash->pList;
|
return (SyHashEntry *)pHash->pList;
|
||||||
}
|
}
|
|
@ -42,11 +42,9 @@ PH7_PRIVATE sxi32 SyBase64Encode(const char *zSrc, sxu32 nLen, ProcConsumer xCon
|
||||||
unsigned char z64[4];
|
unsigned char z64[4];
|
||||||
sxu32 i;
|
sxu32 i;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for(i = 0; i + 2 < nLen; i += 3) {
|
for(i = 0; i + 2 < nLen; i += 3) {
|
||||||
z64[0] = zBase64[(zIn[i] >> 2) & 0x3F];
|
z64[0] = zBase64[(zIn[i] >> 2) & 0x3F];
|
||||||
z64[1] = zBase64[(((zIn[i] & 0x03) << 4) | (zIn[i + 1] >> 4)) & 0x3F];
|
z64[1] = zBase64[(((zIn[i] & 0x03) << 4) | (zIn[i + 1] >> 4)) & 0x3F];
|
||||||
|
@ -89,11 +87,9 @@ PH7_PRIVATE sxi32 SyBase64Decode(const char *zB64, sxu32 nLen, ProcConsumer xCon
|
||||||
sxu32 n, w, x, y, z;
|
sxu32 n, w, x, y, z;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
unsigned char zOut[10];
|
unsigned char zOut[10];
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zB64) || xConsumer == 0) {
|
if(SX_EMPTY_STR(zB64) || xConsumer == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
while(nLen > 0 && zB64[nLen - 1] == '=') {
|
while(nLen > 0 && zB64[nLen - 1] == '=') {
|
||||||
nLen--;
|
nLen--;
|
||||||
}
|
}
|
||||||
|
@ -694,11 +690,9 @@ PH7_PRIVATE sxi32 SyBinToHexConsumer(const void *pIn, sxu32 nLen, ProcConsumer x
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
unsigned char zOut[3];
|
unsigned char zOut[3];
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pIn == 0 || xConsumer == 0) {
|
if(pIn == 0 || xConsumer == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zIn = (const unsigned char *)pIn;
|
zIn = (const unsigned char *)pIn;
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
@ -733,11 +727,9 @@ PH7_PRIVATE sxi32 SyUriDecode(const char *zSrc, sxu32 nLen, ProcConsumer xConsum
|
||||||
sxu8 zOut[10];
|
sxu8 zOut[10];
|
||||||
sxi32 c, d;
|
sxi32 c, d;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = SXRET_OK;
|
rc = SXRET_OK;
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
zCur = zIn;
|
zCur = zIn;
|
||||||
|
@ -806,11 +798,9 @@ PH7_PRIVATE sxi32 SyUriEncode(const char *zSrc, sxu32 nLen, ProcConsumer xConsum
|
||||||
unsigned char *zCur, *zEnd;
|
unsigned char *zCur, *zEnd;
|
||||||
sxi32 c;
|
sxi32 c;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
if(SX_EMPTY_STR(zSrc) || xConsumer == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = SXRET_OK;
|
rc = SXRET_OK;
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
zCur = zIn;
|
zCur = zIn;
|
||||||
|
|
|
@ -687,11 +687,9 @@ static sxi32 FormatMount(sxi32 nType, void *pConsumer, ProcConsumer xUserCons, v
|
||||||
}
|
}
|
||||||
switch(nType) {
|
switch(nType) {
|
||||||
case SXFMT_CONS_PROC:
|
case SXFMT_CONS_PROC:
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(xUserCons == 0) {
|
if(xUserCons == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
sCons.uConsumer.sFunc.xUserConsumer = xUserCons;
|
sCons.uConsumer.sFunc.xUserConsumer = xUserCons;
|
||||||
sCons.uConsumer.sFunc.pUserData = pUserData;
|
sCons.uConsumer.sFunc.pUserData = pUserData;
|
||||||
break;
|
break;
|
||||||
|
@ -710,11 +708,9 @@ static sxi32 FormatMount(sxi32 nType, void *pConsumer, ProcConsumer xUserCons, v
|
||||||
PH7_PRIVATE sxi32 SyProcFormat(ProcConsumer xConsumer, void *pData, const char *zFormat, ...) {
|
PH7_PRIVATE sxi32 SyProcFormat(ProcConsumer xConsumer, void *pData, const char *zFormat, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zFormat)) {
|
if(SX_EMPTY_STR(zFormat)) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
va_start(ap, zFormat);
|
va_start(ap, zFormat);
|
||||||
rc = FormatMount(SXFMT_CONS_PROC, 0, xConsumer, pData, 0, zFormat, ap);
|
rc = FormatMount(SXFMT_CONS_PROC, 0, xConsumer, pData, 0, zFormat, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -723,11 +719,9 @@ PH7_PRIVATE sxi32 SyProcFormat(ProcConsumer xConsumer, void *pData, const char *
|
||||||
PH7_PRIVATE sxu32 SyBlobFormat(SyBlob *pBlob, const char *zFormat, ...) {
|
PH7_PRIVATE sxu32 SyBlobFormat(SyBlob *pBlob, const char *zFormat, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zFormat)) {
|
if(SX_EMPTY_STR(zFormat)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
va_start(ap, zFormat);
|
va_start(ap, zFormat);
|
||||||
FormatMount(SXFMT_CONS_BLOB, &(*pBlob), 0, 0, &n, zFormat, ap);
|
FormatMount(SXFMT_CONS_BLOB, &(*pBlob), 0, 0, &n, zFormat, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -735,11 +729,9 @@ PH7_PRIVATE sxu32 SyBlobFormat(SyBlob *pBlob, const char *zFormat, ...) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxu32 SyBlobFormatAp(SyBlob *pBlob, const char *zFormat, va_list ap) {
|
PH7_PRIVATE sxu32 SyBlobFormatAp(SyBlob *pBlob, const char *zFormat, va_list ap) {
|
||||||
sxu32 n = 0; /* cc warning */
|
sxu32 n = 0; /* cc warning */
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zFormat)) {
|
if(SX_EMPTY_STR(zFormat)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
FormatMount(SXFMT_CONS_BLOB, &(*pBlob), 0, 0, &n, zFormat, ap);
|
FormatMount(SXFMT_CONS_BLOB, &(*pBlob), 0, 0, &n, zFormat, ap);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -747,11 +739,9 @@ PH7_PRIVATE sxu32 SyBufferFormat(char *zBuf, sxu32 nLen, const char *zFormat, ..
|
||||||
SyBlob sBlob;
|
SyBlob sBlob;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zFormat)) {
|
if(SX_EMPTY_STR(zFormat)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(SXRET_OK != SyBlobInitFromBuf(&sBlob, zBuf, nLen - 1)) {
|
if(SXRET_OK != SyBlobInitFromBuf(&sBlob, zBuf, nLen - 1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,11 +391,9 @@ static sxi32 ZipExtract(SyArchive *pArch, const unsigned char *zCentral, sxu32 n
|
||||||
PH7_PRIVATE sxi32 SyZipExtractFromBuf(SyArchive *pArch, const char *zBuf, sxu32 nLen) {
|
PH7_PRIVATE sxi32 SyZipExtractFromBuf(SyArchive *pArch, const char *zBuf, sxu32 nLen) {
|
||||||
const unsigned char *zCentral, *zEnd;
|
const unsigned char *zCentral, *zEnd;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXARCH_INVALID(pArch) || zBuf == 0) {
|
if(SXARCH_INVALID(pArch) || zBuf == 0) {
|
||||||
return SXERR_INVALID;
|
return SXERR_INVALID;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* The miminal size of a zip archive:
|
/* The miminal size of a zip archive:
|
||||||
* LOCAL_HDR_SZ + CENTRAL_HDR_SZ + END_OF_CENTRAL_HDR_SZ
|
* LOCAL_HDR_SZ + CENTRAL_HDR_SZ + END_OF_CENTRAL_HDR_SZ
|
||||||
* 30 46 22
|
* 30 46 22
|
||||||
|
@ -441,11 +439,9 @@ static sxi32 ArchiveHashCmp(const SyString *pStr1, const SyString *pStr2) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyArchiveInit(SyArchive *pArch, SyMemBackend *pAllocator, ProcHash xHash, ProcRawStrCmp xCmp) {
|
PH7_PRIVATE sxi32 SyArchiveInit(SyArchive *pArch, SyMemBackend *pAllocator, ProcHash xHash, ProcRawStrCmp xCmp) {
|
||||||
SyArchiveEntry **apHash;
|
SyArchiveEntry **apHash;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pArch == 0) {
|
if(pArch == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
SyZero(pArch, sizeof(SyArchive));
|
SyZero(pArch, sizeof(SyArchive));
|
||||||
/* Allocate a new hashtable */
|
/* Allocate a new hashtable */
|
||||||
apHash = (SyArchiveEntry **)SyMemBackendAlloc(&(*pAllocator), SXARCHIVE_HASH_SIZE * sizeof(SyArchiveEntry *));
|
apHash = (SyArchiveEntry **)SyMemBackendAlloc(&(*pAllocator), SXARCHIVE_HASH_SIZE * sizeof(SyArchiveEntry *));
|
||||||
|
|
|
@ -42,11 +42,9 @@ static void SyOSHeapFree(void *pPtr) {
|
||||||
PH7_PRIVATE void SyZero(void *pSrc, sxu32 nSize) {
|
PH7_PRIVATE void SyZero(void *pSrc, sxu32 nSize) {
|
||||||
register unsigned char *zSrc = (unsigned char *)pSrc;
|
register unsigned char *zSrc = (unsigned char *)pSrc;
|
||||||
unsigned char *zEnd;
|
unsigned char *zEnd;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(zSrc == 0 || nSize <= 0) {
|
if(zSrc == 0 || nSize <= 0) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nSize];
|
zEnd = &zSrc[nSize];
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(zSrc >= zEnd) {
|
if(zSrc >= zEnd) {
|
||||||
|
@ -68,11 +66,9 @@ PH7_PRIVATE sxi32 SyMemcmp(const void *pB1, const void *pB2, sxu32 nSize) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxu32 SyMemcpy(const void *pSrc, void *pDest, sxu32 nLen) {
|
PH7_PRIVATE sxu32 SyMemcpy(const void *pSrc, void *pDest, sxu32 nLen) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pSrc == 0 || pDest == 0) {
|
if(pSrc == 0 || pDest == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pSrc == (const void *)pDest) {
|
if(pSrc == (const void *)pDest) {
|
||||||
return nLen;
|
return nLen;
|
||||||
}
|
}
|
||||||
|
@ -160,19 +156,15 @@ static void *MemBackendAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
||||||
pBlock->pNext = pBlock->pPrev = 0;
|
pBlock->pNext = pBlock->pPrev = 0;
|
||||||
/* Link to the list of already tracked blocks */
|
/* Link to the list of already tracked blocks */
|
||||||
MACRO_LD_PUSH(pBackend->pBlocks, pBlock);
|
MACRO_LD_PUSH(pBackend->pBlocks, pBlock);
|
||||||
#if defined(UNTRUST)
|
|
||||||
pBlock->nGuard = SXMEM_BACKEND_MAGIC;
|
pBlock->nGuard = SXMEM_BACKEND_MAGIC;
|
||||||
#endif
|
|
||||||
pBackend->nBlock++;
|
pBackend->nBlock++;
|
||||||
return (void *)&pBlock[1];
|
return (void *)&pBlock[1];
|
||||||
}
|
}
|
||||||
PH7_PRIVATE void *SyMemBackendAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
PH7_PRIVATE void *SyMemBackendAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
||||||
void *pChunk;
|
void *pChunk;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -190,11 +182,9 @@ static void *MemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes)
|
||||||
return MemBackendAlloc(&(*pBackend), nBytes);
|
return MemBackendAlloc(&(*pBackend), nBytes);
|
||||||
}
|
}
|
||||||
pBlock = (SyMemBlock *)(((char *)pOld) - sizeof(SyMemBlock));
|
pBlock = (SyMemBlock *)(((char *)pOld) - sizeof(SyMemBlock));
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBlock->nGuard != SXMEM_BACKEND_MAGIC) {
|
if(pBlock->nGuard != SXMEM_BACKEND_MAGIC) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
nBytes += sizeof(SyMemBlock);
|
nBytes += sizeof(SyMemBlock);
|
||||||
pPrev = pBlock->pPrev;
|
pPrev = pBlock->pPrev;
|
||||||
pNext = pBlock->pNext;
|
pNext = pBlock->pNext;
|
||||||
|
@ -224,9 +214,7 @@ static void *MemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes)
|
||||||
if(pNext) {
|
if(pNext) {
|
||||||
pNext->pPrev = pNew;
|
pNext->pPrev = pNew;
|
||||||
}
|
}
|
||||||
#if defined(UNTRUST)
|
|
||||||
pNew->nGuard = SXMEM_BACKEND_MAGIC;
|
pNew->nGuard = SXMEM_BACKEND_MAGIC;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pNew = pBlock;
|
pNew = pBlock;
|
||||||
|
@ -235,11 +223,9 @@ static void *MemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes)
|
||||||
}
|
}
|
||||||
PH7_PRIVATE void *SyMemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes) {
|
PH7_PRIVATE void *SyMemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes) {
|
||||||
void *pChunk;
|
void *pChunk;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -253,18 +239,14 @@ static sxi32 MemBackendFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
SyMemBlock *pBlock;
|
SyMemBlock *pBlock;
|
||||||
sxu32 *pChunkSize;
|
sxu32 *pChunkSize;
|
||||||
pBlock = (SyMemBlock *)(((char *)pChunk) - sizeof(SyMemBlock));
|
pBlock = (SyMemBlock *)(((char *)pChunk) - sizeof(SyMemBlock));
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBlock->nGuard != SXMEM_BACKEND_MAGIC) {
|
if(pBlock->nGuard != SXMEM_BACKEND_MAGIC) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Unlink from the list of active blocks */
|
/* Unlink from the list of active blocks */
|
||||||
if(pBackend->nBlock > 0) {
|
if(pBackend->nBlock > 0) {
|
||||||
/* Release the block */
|
/* Release the block */
|
||||||
#if defined(UNTRUST)
|
|
||||||
/* Mark as stale block */
|
/* Mark as stale block */
|
||||||
pBlock->nGuard = 0x635B;
|
pBlock->nGuard = 0x635B;
|
||||||
#endif
|
|
||||||
MACRO_LD_REMOVE(pBackend->pBlocks, pBlock);
|
MACRO_LD_REMOVE(pBackend->pBlocks, pBlock);
|
||||||
pBackend->nBlock--;
|
pBackend->nBlock--;
|
||||||
/* Release the heap */
|
/* Release the heap */
|
||||||
|
@ -276,11 +258,9 @@ static sxi32 MemBackendFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendFree(SyMemBackend *pBackend, void *pChunk) {
|
PH7_PRIVATE sxi32 SyMemBackendFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pChunk == 0) {
|
if(pChunk == 0) {
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
|
@ -295,11 +275,9 @@ PH7_PRIVATE sxi32 SyMemBackendFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMutexMethods *pMethods) {
|
PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMutexMethods *pMethods) {
|
||||||
SyMutex *pMutex;
|
SyMutex *pMutex;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend) || pMethods == 0 || pMethods->xNew == 0) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend) || pMethods == 0 || pMethods->xNew == 0) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pMutex = pMethods->xNew(SXMUTEX_TYPE_FAST);
|
pMutex = pMethods->xNew(SXMUTEX_TYPE_FAST);
|
||||||
if(pMutex == 0) {
|
if(pMutex == 0) {
|
||||||
return SXERR_OS;
|
return SXERR_OS;
|
||||||
|
@ -310,11 +288,9 @@ PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMut
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend) {
|
PH7_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutex == 0) {
|
if(pBackend->pMutex == 0) {
|
||||||
/* There is no mutex subsystem at all */
|
/* There is no mutex subsystem at all */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
|
@ -394,11 +370,9 @@ static void *MemBackendPoolAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE void *SyMemBackendPoolAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
PH7_PRIVATE void *SyMemBackendPoolAlloc(SyMemBackend *pBackend, sxu32 nBytes) {
|
||||||
void *pChunk;
|
void *pChunk;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -430,11 +404,9 @@ static sxi32 MemBackendPoolFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendPoolFree(SyMemBackend *pBackend, void *pChunk) {
|
PH7_PRIVATE sxi32 SyMemBackendPoolFree(SyMemBackend *pBackend, void *pChunk) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend) || pChunk == 0) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend) || pChunk == 0) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -482,11 +454,9 @@ static void *MemBackendPoolRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBy
|
||||||
}
|
}
|
||||||
PH7_PRIVATE void *SyMemBackendPoolRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nByte) {
|
PH7_PRIVATE void *SyMemBackendPoolRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nByte) {
|
||||||
void *pChunk;
|
void *pChunk;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -497,11 +467,9 @@ PH7_PRIVATE void *SyMemBackendPoolRealloc(SyMemBackend *pBackend, void *pOld, sx
|
||||||
return pChunk;
|
return pChunk;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendInit(SyMemBackend *pBackend, ProcMemError xMemErr, void *pUserData) {
|
PH7_PRIVATE sxi32 SyMemBackendInit(SyMemBackend *pBackend, ProcMemError xMemErr, void *pUserData) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBackend == 0) {
|
if(pBackend == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Zero the allocator first */
|
/* Zero the allocator first */
|
||||||
SyZero(&(*pBackend), sizeof(SyMemBackend));
|
SyZero(&(*pBackend), sizeof(SyMemBackend));
|
||||||
pBackend->xMemError = xMemErr;
|
pBackend->xMemError = xMemErr;
|
||||||
|
@ -520,17 +488,13 @@ PH7_PRIVATE sxi32 SyMemBackendInit(SyMemBackend *pBackend, ProcMemError xMemErr,
|
||||||
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
||||||
return SXERR_OS;
|
return SXERR_OS;
|
||||||
}
|
}
|
||||||
#if defined(UNTRUST)
|
|
||||||
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
||||||
#endif
|
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendInitFromOthers(SyMemBackend *pBackend, const SyMemMethods *pMethods, ProcMemError xMemErr, void *pUserData) {
|
PH7_PRIVATE sxi32 SyMemBackendInitFromOthers(SyMemBackend *pBackend, const SyMemMethods *pMethods, ProcMemError xMemErr, void *pUserData) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBackend == 0 || pMethods == 0) {
|
if(pBackend == 0 || pMethods == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pMethods->xAlloc == 0 || pMethods->xRealloc == 0 || pMethods->xFree == 0 || pMethods->xChunkSize == 0) {
|
if(pMethods->xAlloc == 0 || pMethods->xRealloc == 0 || pMethods->xFree == 0 || pMethods->xChunkSize == 0) {
|
||||||
/* mandatory methods are missing */
|
/* mandatory methods are missing */
|
||||||
return SXERR_INVALID;
|
return SXERR_INVALID;
|
||||||
|
@ -553,17 +517,13 @@ PH7_PRIVATE sxi32 SyMemBackendInitFromOthers(SyMemBackend *pBackend, const SyMem
|
||||||
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
||||||
return SXERR_OS;
|
return SXERR_OS;
|
||||||
}
|
}
|
||||||
#if defined(UNTRUST)
|
|
||||||
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
||||||
#endif
|
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendInitFromParent(SyMemBackend *pBackend, SyMemBackend *pParent) {
|
PH7_PRIVATE sxi32 SyMemBackendInitFromParent(SyMemBackend *pBackend, SyMemBackend *pParent) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBackend == 0 || SXMEM_BACKEND_CORRUPT(pParent)) {
|
if(pBackend == 0 || SXMEM_BACKEND_CORRUPT(pParent)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Zero the allocator first */
|
/* Zero the allocator first */
|
||||||
SyZero(&(*pBackend), sizeof(SyMemBackend));
|
SyZero(&(*pBackend), sizeof(SyMemBackend));
|
||||||
/* Reinitialize the allocator */
|
/* Reinitialize the allocator */
|
||||||
|
@ -583,9 +543,7 @@ PH7_PRIVATE sxi32 SyMemBackendInitFromParent(SyMemBackend *pBackend, SyMemBacken
|
||||||
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
if(MemBackendCalculate(pBackend, sizeof(SyMemHeap)) != SXRET_OK) {
|
||||||
return SXERR_OS;
|
return SXERR_OS;
|
||||||
}
|
}
|
||||||
#if defined(UNTRUST)
|
|
||||||
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
pBackend->nMagic = SXMEM_BACKEND_MAGIC;
|
||||||
#endif
|
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
static sxi32 MemBackendRelease(SyMemBackend *pBackend) {
|
static sxi32 MemBackendRelease(SyMemBackend *pBackend) {
|
||||||
|
@ -605,17 +563,14 @@ static sxi32 MemBackendRelease(SyMemBackend *pBackend) {
|
||||||
}
|
}
|
||||||
pBackend->pMethods = 0;
|
pBackend->pMethods = 0;
|
||||||
pBackend->pBlocks = 0;
|
pBackend->pBlocks = 0;
|
||||||
#if defined(UNTRUST)
|
|
||||||
pBackend->nMagic = 0x2626;
|
pBackend->nMagic = 0x2626;
|
||||||
#endif
|
#
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyMemBackendRelease(SyMemBackend *pBackend) {
|
PH7_PRIVATE sxi32 SyMemBackendRelease(SyMemBackend *pBackend) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
if(SXMEM_BACKEND_CORRUPT(pBackend)) {
|
||||||
return SXERR_INVALID;
|
return SXERR_INVALID;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pBackend->pMutexMethods) {
|
if(pBackend->pMutexMethods) {
|
||||||
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
SyMutexEnter(pBackend->pMutexMethods, pBackend->pMutex);
|
||||||
}
|
}
|
||||||
|
@ -628,11 +583,9 @@ PH7_PRIVATE sxi32 SyMemBackendRelease(SyMemBackend *pBackend) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE void *SyMemBackendDup(SyMemBackend *pBackend, const void *pSrc, sxu32 nSize) {
|
PH7_PRIVATE void *SyMemBackendDup(SyMemBackend *pBackend, const void *pSrc, sxu32 nSize) {
|
||||||
void *pNew;
|
void *pNew;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pSrc == 0 || nSize <= 0) {
|
if(pSrc == 0 || nSize <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pNew = SyMemBackendAlloc(&(*pBackend), nSize);
|
pNew = SyMemBackendAlloc(&(*pBackend), nSize);
|
||||||
if(pNew) {
|
if(pNew) {
|
||||||
SyMemcpy(pSrc, pNew, nSize);
|
SyMemcpy(pSrc, pNew, nSize);
|
||||||
|
@ -648,11 +601,9 @@ PH7_PRIVATE char *SyMemBackendStrDup(SyMemBackend *pBackend, const char *zSrc, s
|
||||||
return zDest;
|
return zDest;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyBlobInitFromBuf(SyBlob *pBlob, void *pBuffer, sxu32 nSize) {
|
PH7_PRIVATE sxi32 SyBlobInitFromBuf(SyBlob *pBlob, void *pBuffer, sxu32 nSize) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBlob == 0 || pBuffer == 0 || nSize < 1) {
|
if(pBlob == 0 || pBuffer == 0 || nSize < 1) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pBlob->pBlob = pBuffer;
|
pBlob->pBlob = pBuffer;
|
||||||
pBlob->mByte = nSize;
|
pBlob->mByte = nSize;
|
||||||
pBlob->nByte = 0;
|
pBlob->nByte = 0;
|
||||||
|
@ -661,11 +612,9 @@ PH7_PRIVATE sxi32 SyBlobInitFromBuf(SyBlob *pBlob, void *pBuffer, sxu32 nSize) {
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyBlobInit(SyBlob *pBlob, SyMemBackend *pAllocator) {
|
PH7_PRIVATE sxi32 SyBlobInit(SyBlob *pBlob, SyMemBackend *pAllocator) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBlob == 0) {
|
if(pBlob == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pBlob->pBlob = 0;
|
pBlob->pBlob = 0;
|
||||||
pBlob->mByte = pBlob->nByte = 0;
|
pBlob->mByte = pBlob->nByte = 0;
|
||||||
pBlob->pAllocator = &(*pAllocator);
|
pBlob->pAllocator = &(*pAllocator);
|
||||||
|
@ -673,11 +622,9 @@ PH7_PRIVATE sxi32 SyBlobInit(SyBlob *pBlob, SyMemBackend *pAllocator) {
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyBlobReadOnly(SyBlob *pBlob, const void *pData, sxu32 nByte) {
|
PH7_PRIVATE sxi32 SyBlobReadOnly(SyBlob *pBlob, const void *pData, sxu32 nByte) {
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pBlob == 0) {
|
if(pBlob == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pBlob->pBlob = (void *)pData;
|
pBlob->pBlob = (void *)pData;
|
||||||
pBlob->nByte = nByte;
|
pBlob->nByte = nByte;
|
||||||
pBlob->mByte = 0;
|
pBlob->mByte = 0;
|
||||||
|
@ -762,11 +709,9 @@ PH7_PRIVATE sxi32 SyBlobNullAppend(SyBlob *pBlob) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyBlobDup(SyBlob *pSrc, SyBlob *pDest) {
|
PH7_PRIVATE sxi32 SyBlobDup(SyBlob *pSrc, SyBlob *pDest) {
|
||||||
sxi32 rc = SXRET_OK;
|
sxi32 rc = SXRET_OK;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pSrc == 0 || pDest == 0) {
|
if(pSrc == 0 || pDest == 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pSrc->nByte > 0) {
|
if(pSrc->nByte > 0) {
|
||||||
rc = SyBlobAppend(&(*pDest), pSrc->pBlob, pSrc->nByte);
|
rc = SyBlobAppend(&(*pDest), pSrc->pBlob, pSrc->nByte);
|
||||||
}
|
}
|
||||||
|
@ -774,11 +719,9 @@ PH7_PRIVATE sxi32 SyBlobDup(SyBlob *pSrc, SyBlob *pDest) {
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyBlobCmp(SyBlob *pLeft, SyBlob *pRight) {
|
PH7_PRIVATE sxi32 SyBlobCmp(SyBlob *pLeft, SyBlob *pRight) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pLeft == 0 || pRight == 0) {
|
if(pLeft == 0 || pRight == 0) {
|
||||||
return pLeft ? 1 : -1;
|
return pLeft ? 1 : -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pLeft->nByte != pRight->nByte) {
|
if(pLeft->nByte != pRight->nByte) {
|
||||||
/* Length differ */
|
/* Length differ */
|
||||||
return pLeft->nByte - pRight->nByte;
|
return pLeft->nByte - pRight->nByte;
|
||||||
|
|
|
@ -108,11 +108,9 @@ static sxu8 randomByte(SyPRNGCtx *pCtx) {
|
||||||
PH7_PRIVATE sxi32 SyRandomness(SyPRNGCtx *pCtx, void *pBuf, sxu32 nLen) {
|
PH7_PRIVATE sxi32 SyRandomness(SyPRNGCtx *pCtx, void *pBuf, sxu32 nLen) {
|
||||||
unsigned char *zBuf = (unsigned char *)pBuf;
|
unsigned char *zBuf = (unsigned char *)pBuf;
|
||||||
unsigned char *zEnd = &zBuf[nLen];
|
unsigned char *zEnd = &zBuf[nLen];
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(pCtx == 0 || pBuf == 0 || nLen <= 0) {
|
if(pCtx == 0 || pBuf == 0 || nLen <= 0) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pCtx->nMagic != SXPRNG_MAGIC) {
|
if(pCtx->nMagic != SXPRNG_MAGIC) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,9 @@
|
||||||
|
|
||||||
PH7_PRIVATE sxu32 SyStrlen(const char *zSrc) {
|
PH7_PRIVATE sxu32 SyStrlen(const char *zSrc) {
|
||||||
register const char *zIn = zSrc;
|
register const char *zIn = zSrc;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(zIn == 0) {
|
if(zIn == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(!zIn[0]) {
|
if(!zIn[0]) {
|
||||||
break;
|
break;
|
||||||
|
@ -126,11 +124,9 @@ sxu32 Systrcpy(char *zDest, sxu32 nDestLen, const char *zSrc, sxu32 nLen) {
|
||||||
unsigned char *zBuf = (unsigned char *)zDest;
|
unsigned char *zBuf = (unsigned char *)zDest;
|
||||||
unsigned char *zIn = (unsigned char *)zSrc;
|
unsigned char *zIn = (unsigned char *)zSrc;
|
||||||
unsigned char *zEnd;
|
unsigned char *zEnd;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(zSrc == (const char *)zDest) {
|
if(zSrc == (const char *)zDest) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(nLen <= 0) {
|
if(nLen <= 0) {
|
||||||
nLen = SyStrlen(zSrc);
|
nLen = SyStrlen(zSrc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,9 @@
|
||||||
|
|
||||||
PH7_PRIVATE sxi32 SyLexInit(SyLex *pLex, SySet *pSet, ProcTokenizer xTokenizer, void *pUserData) {
|
PH7_PRIVATE sxi32 SyLexInit(SyLex *pLex, SySet *pSet, ProcTokenizer xTokenizer, void *pUserData) {
|
||||||
SyStream *pStream;
|
SyStream *pStream;
|
||||||
#if defined (UNTRUST)
|
|
||||||
if(pLex == 0 || xTokenizer == 0) {
|
if(pLex == 0 || xTokenizer == 0) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pLex->pTokenSet = 0;
|
pLex->pTokenSet = 0;
|
||||||
/* Initialize lexer fields */
|
/* Initialize lexer fields */
|
||||||
if(pSet) {
|
if(pSet) {
|
||||||
|
@ -39,11 +37,9 @@ PH7_PRIVATE sxi32 SyLexTokenizeInput(SyLex *pLex, const char *zInput, sxu32 nLen
|
||||||
SyStream *pStream;
|
SyStream *pStream;
|
||||||
SyToken sToken;
|
SyToken sToken;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#if defined (UNTRUST)
|
|
||||||
if(INVALID_LEXER(pLex) || zInput == 0) {
|
if(INVALID_LEXER(pLex) || zInput == 0) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pStream = &pLex->sStream;
|
pStream = &pLex->sStream;
|
||||||
/* Point to the head of the input */
|
/* Point to the head of the input */
|
||||||
pStream->zText = pStream->zInput = (const unsigned char *)zInput;
|
pStream->zText = pStream->zInput = (const unsigned char *)zInput;
|
||||||
|
@ -92,12 +88,8 @@ PH7_PRIVATE sxi32 SyLexTokenizeInput(SyLex *pLex, const char *zInput, sxu32 nLen
|
||||||
}
|
}
|
||||||
PH7_PRIVATE sxi32 SyLexRelease(SyLex *pLex) {
|
PH7_PRIVATE sxi32 SyLexRelease(SyLex *pLex) {
|
||||||
sxi32 rc = SXRET_OK;
|
sxi32 rc = SXRET_OK;
|
||||||
#if defined (UNTRUST)
|
|
||||||
if(INVALID_LEXER(pLex)) {
|
if(INVALID_LEXER(pLex)) {
|
||||||
return SXERR_CORRUPT;
|
return SXERR_CORRUPT;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
SXUNUSED(pLex); /* Prevent compiler warning */
|
|
||||||
#endif
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
|
@ -10,11 +10,9 @@
|
||||||
|
|
||||||
PH7_PRIVATE sxi32 SyStrIsNumeric(const char *zSrc, sxu32 nLen, sxu8 *pReal, const char **pzTail) {
|
PH7_PRIVATE sxi32 SyStrIsNumeric(const char *zSrc, sxu32 nLen, sxu8 *pReal, const char **pzTail) {
|
||||||
const char *zCur, *zEnd;
|
const char *zCur, *zEnd;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
/* Jump leading white spaces */
|
/* Jump leading white spaces */
|
||||||
while(zSrc < zEnd && (unsigned char)zSrc[0] < 0xc0 && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && (unsigned char)zSrc[0] < 0xc0 && SyisSpace(zSrc[0])) {
|
||||||
|
@ -84,14 +82,12 @@ PH7_PRIVATE sxi32 SyStrToInt32(const char *zSrc, sxu32 nLen, void *pOutVal, cons
|
||||||
const char *zEnd;
|
const char *zEnd;
|
||||||
sxi32 nVal = 0;
|
sxi32 nVal = 0;
|
||||||
sxi16 i;
|
sxi16 i;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxi32 *)pOutVal = 0;
|
*(sxi32 *)pOutVal = 0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
@ -137,14 +133,12 @@ PH7_PRIVATE sxi32 SyStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, cons
|
||||||
const char *zEnd;
|
const char *zEnd;
|
||||||
sxi64 nVal;
|
sxi64 nVal;
|
||||||
sxi16 i;
|
sxi16 i;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxi32 *)pOutVal = 0;
|
*(sxi32 *)pOutVal = 0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
@ -232,14 +226,12 @@ PH7_PRIVATE sxi32 SyHexStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, c
|
||||||
const char *zIn, *zEnd;
|
const char *zIn, *zEnd;
|
||||||
int isNeg = FALSE;
|
int isNeg = FALSE;
|
||||||
sxi64 nVal = 0;
|
sxi64 nVal = 0;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxi32 *)pOutVal = 0;
|
*(sxi32 *)pOutVal = 0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
@ -298,14 +290,12 @@ PH7_PRIVATE sxi32 SyOctalStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal,
|
||||||
int isNeg = FALSE;
|
int isNeg = FALSE;
|
||||||
sxi64 nVal = 0;
|
sxi64 nVal = 0;
|
||||||
int c;
|
int c;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxi32 *)pOutVal = 0;
|
*(sxi32 *)pOutVal = 0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
@ -349,14 +339,12 @@ PH7_PRIVATE sxi32 SyBinaryStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal
|
||||||
int isNeg = FALSE;
|
int isNeg = FALSE;
|
||||||
sxi64 nVal = 0;
|
sxi64 nVal = 0;
|
||||||
int c;
|
int c;
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxi32 *)pOutVal = 0;
|
*(sxi32 *)pOutVal = 0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
@ -417,14 +405,12 @@ PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const
|
||||||
const char *zEnd;
|
const char *zEnd;
|
||||||
sxi32 Lim, exp;
|
sxi32 Lim, exp;
|
||||||
sxreal *p = 0;
|
sxreal *p = 0;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(SX_EMPTY_STR(zSrc)) {
|
if(SX_EMPTY_STR(zSrc)) {
|
||||||
if(pOutVal) {
|
if(pOutVal) {
|
||||||
*(sxreal *)pOutVal = 0.0;
|
*(sxreal *)pOutVal = 0.0;
|
||||||
}
|
}
|
||||||
return SXERR_EMPTY;
|
return SXERR_EMPTY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
zEnd = &zSrc[nLen];
|
zEnd = &zSrc[nLen];
|
||||||
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
while(zSrc < zEnd && SyisSpace(zSrc[0])) {
|
||||||
zSrc++;
|
zSrc++;
|
||||||
|
|
103
engine/vm.c
103
engine/vm.c
|
@ -1492,12 +1492,10 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
|
||||||
ProcConsumer xConsumer = va_arg(ap, ProcConsumer);
|
ProcConsumer xConsumer = va_arg(ap, ProcConsumer);
|
||||||
void *pUserData = va_arg(ap, void *);
|
void *pUserData = va_arg(ap, void *);
|
||||||
/* VM output consumer callback */
|
/* VM output consumer callback */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(xConsumer == 0) {
|
if(xConsumer == 0) {
|
||||||
rc = SXERR_CORRUPT;
|
rc = SXERR_CORRUPT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Install the output consumer */
|
/* Install the output consumer */
|
||||||
pVm->sVmConsumer.xConsumer = xConsumer;
|
pVm->sVmConsumer.xConsumer = xConsumer;
|
||||||
pVm->sVmConsumer.pUserData = pUserData;
|
pVm->sVmConsumer.pUserData = pUserData;
|
||||||
|
@ -1508,12 +1506,10 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
|
||||||
const char *zPath;
|
const char *zPath;
|
||||||
SyString sPath;
|
SyString sPath;
|
||||||
zPath = va_arg(ap, const char *);
|
zPath = va_arg(ap, const char *);
|
||||||
#if defined(UNTRUST)
|
|
||||||
if(zPath == 0) {
|
if(zPath == 0) {
|
||||||
rc = SXERR_EMPTY;
|
rc = SXERR_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
SyStringInitFromBuf(&sPath, zPath, SyStrlen(zPath));
|
SyStringInitFromBuf(&sPath, zPath, SyStrlen(zPath));
|
||||||
/* Remove trailing slashes and backslashes */
|
/* Remove trailing slashes and backslashes */
|
||||||
#ifdef __WINNT__
|
#ifdef __WINNT__
|
||||||
|
@ -1541,12 +1537,10 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxu32 nByte;
|
sxu32 nByte;
|
||||||
sxu32 nIdx;
|
sxu32 nIdx;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(SX_EMPTY_STR(zName) || pValue == 0) {
|
if(SX_EMPTY_STR(zName) || pValue == 0) {
|
||||||
rc = SXERR_CORRUPT;
|
rc = SXERR_CORRUPT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
nByte = SyStrlen(zName);
|
nByte = SyStrlen(zName);
|
||||||
if(nOp == PH7_VM_CONFIG_CREATE_SUPER) {
|
if(nOp == PH7_VM_CONFIG_CREATE_SUPER) {
|
||||||
/* Check if the superglobal is already installed */
|
/* Check if the superglobal is already installed */
|
||||||
|
@ -1676,12 +1670,10 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
|
||||||
/* Point to the VM internal output consumer buffer */
|
/* Point to the VM internal output consumer buffer */
|
||||||
const void **ppOut = va_arg(ap, const void **);
|
const void **ppOut = va_arg(ap, const void **);
|
||||||
unsigned int *pLen = va_arg(ap, unsigned int *);
|
unsigned int *pLen = va_arg(ap, unsigned int *);
|
||||||
#ifdef UNTRUST
|
|
||||||
if(ppOut == 0 || pLen == 0) {
|
if(ppOut == 0 || pLen == 0) {
|
||||||
rc = SXERR_CORRUPT;
|
rc = SXERR_CORRUPT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*ppOut = SyBlobData(&pVm->sConsumer);
|
*ppOut = SyBlobData(&pVm->sConsumer);
|
||||||
*pLen = SyBlobLength(&pVm->sConsumer);
|
*pLen = SyBlobLength(&pVm->sConsumer);
|
||||||
break;
|
break;
|
||||||
|
@ -2005,11 +1997,9 @@ static sxi32 VmByteCodeExec(
|
||||||
*/
|
*/
|
||||||
case PH7_OP_DONE:
|
case PH7_OP_DONE:
|
||||||
if(pInstr->iP1) {
|
if(pInstr->iP1) {
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pLastRef) {
|
if(pLastRef) {
|
||||||
*pLastRef = pTos->nIdx;
|
*pLastRef = pTos->nIdx;
|
||||||
}
|
}
|
||||||
|
@ -2052,11 +2042,9 @@ static sxi32 VmByteCodeExec(
|
||||||
*/
|
*/
|
||||||
case PH7_OP_HALT:
|
case PH7_OP_HALT:
|
||||||
if(pInstr->iP1) {
|
if(pInstr->iP1) {
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pLastRef) {
|
if(pLastRef) {
|
||||||
*pLastRef = pTos->nIdx;
|
*pLastRef = pTos->nIdx;
|
||||||
}
|
}
|
||||||
|
@ -2093,11 +2081,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* entry in the stack if P1 is zero.
|
* entry in the stack if P1 is zero.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_JMPZ:
|
case PH7_OP_JMPZ:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Get a boolean value */
|
/* Get a boolean value */
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
|
@ -2117,11 +2103,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* entry in the stack if P1 is zero.
|
* entry in the stack if P1 is zero.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_JMPNZ:
|
case PH7_OP_JMPNZ:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Get a boolean value */
|
/* Get a boolean value */
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
|
@ -2188,11 +2172,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be an integer.
|
* Force the top of the stack to be an integer.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_INT:
|
case PH7_OP_CVT_INT:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
}
|
}
|
||||||
|
@ -2205,11 +2187,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a real.
|
* Force the top of the stack to be a real.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_REAL:
|
case PH7_OP_CVT_REAL:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
||||||
PH7_MemObjToReal(pTos);
|
PH7_MemObjToReal(pTos);
|
||||||
}
|
}
|
||||||
|
@ -2222,11 +2202,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a string.
|
* Force the top of the stack to be a string.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_STR:
|
case PH7_OP_CVT_STR:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_STRING) == 0) {
|
if((pTos->nType & MEMOBJ_STRING) == 0) {
|
||||||
PH7_MemObjToString(pTos);
|
PH7_MemObjToString(pTos);
|
||||||
}
|
}
|
||||||
|
@ -2237,11 +2215,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a boolean.
|
* Force the top of the stack to be a boolean.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_BOOL:
|
case PH7_OP_CVT_BOOL:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
}
|
}
|
||||||
|
@ -2252,11 +2228,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a char.
|
* Force the top of the stack to be a char.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_CHAR:
|
case PH7_OP_CVT_CHAR:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_CHAR) == 0) {
|
if((pTos->nType & MEMOBJ_CHAR) == 0) {
|
||||||
PH7_MemObjToChar(pTos);
|
PH7_MemObjToChar(pTos);
|
||||||
}
|
}
|
||||||
|
@ -2269,11 +2243,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a class instance (Object in the PHP jargon).
|
* Force the top of the stack to be a class instance (Object in the PHP jargon).
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_OBJ:
|
case PH7_OP_CVT_OBJ:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & MEMOBJ_OBJ) == 0) {
|
if((pTos->nType & MEMOBJ_OBJ) == 0) {
|
||||||
/* Force a 'stdClass()' cast */
|
/* Force a 'stdClass()' cast */
|
||||||
PH7_MemObjToObject(pTos);
|
PH7_MemObjToObject(pTos);
|
||||||
|
@ -2285,11 +2257,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a callback
|
* Force the top of the stack to be a callback
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_CALL:
|
case PH7_OP_CVT_CALL:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PH7_MemObjToCallback(pTos);
|
PH7_MemObjToCallback(pTos);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
|
@ -2298,11 +2268,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a resource
|
* Force the top of the stack to be a resource
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_RES:
|
case PH7_OP_CVT_RES:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PH7_MemObjToResource(pTos);
|
PH7_MemObjToResource(pTos);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
|
@ -2311,11 +2279,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Force the top of the stack to be a void type.
|
* Force the top of the stack to be a void type.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CVT_VOID:
|
case PH7_OP_CVT_VOID:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PH7_MemObjToVoid(pTos);
|
PH7_MemObjToVoid(pTos);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
|
@ -2329,11 +2295,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_IS: {
|
case PH7_OP_IS: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi32 iRes = 0; /* assume false by default */
|
sxi32 iRes = 0; /* assume false by default */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pInstr->iP2) {
|
if(pInstr->iP2) {
|
||||||
sxu32 nType = pNos->nType;
|
sxu32 nType = pNos->nType;
|
||||||
if(nType & MEMOBJ_MIXED) {
|
if(nType & MEMOBJ_MIXED) {
|
||||||
|
@ -2490,11 +2454,10 @@ static sxi32 VmByteCodeExec(
|
||||||
SyString sName;
|
SyString sName;
|
||||||
if(pInstr->p3 == 0) {
|
if(pInstr->p3 == 0) {
|
||||||
/* Take the variable name from the top of the stack */
|
/* Take the variable name from the top of the stack */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
#
|
||||||
/* Force a string cast */
|
/* Force a string cast */
|
||||||
if((pTos->nType & MEMOBJ_STRING) == 0) {
|
if((pTos->nType & MEMOBJ_STRING) == 0) {
|
||||||
PH7_MemObjToString(pTos);
|
PH7_MemObjToString(pTos);
|
||||||
|
@ -2721,11 +2684,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_STORE: {
|
case PH7_OP_STORE: {
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
SyString sName;
|
SyString sName;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pInstr->iP2) {
|
if(pInstr->iP2) {
|
||||||
sxu32 nIdx;
|
sxu32 nIdx;
|
||||||
/* Member store operation */
|
/* Member store operation */
|
||||||
|
@ -2756,11 +2717,9 @@ static sxi32 VmByteCodeExec(
|
||||||
}
|
}
|
||||||
SyStringInitFromBuf(&sName, SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
|
SyStringInitFromBuf(&sName, SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
|
||||||
pTos--;
|
pTos--;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
|
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
|
||||||
}
|
}
|
||||||
|
@ -2893,11 +2852,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* the stack and increment after that.
|
* the stack and increment after that.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_INCR:
|
case PH7_OP_INCR:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES)) == 0) {
|
if((pTos->nType & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES)) == 0) {
|
||||||
if(pTos->nIdx != SXU32_HIGH) {
|
if(pTos->nIdx != SXU32_HIGH) {
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
|
@ -2938,11 +2895,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* and decrement after that.
|
* and decrement after that.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_DECR:
|
case PH7_OP_DECR:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if((pTos->nType & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES | MEMOBJ_NULL)) == 0) {
|
if((pTos->nType & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES | MEMOBJ_NULL)) == 0) {
|
||||||
/* Force a numeric cast */
|
/* Force a numeric cast */
|
||||||
PH7_MemObjToNumeric(pTos);
|
PH7_MemObjToNumeric(pTos);
|
||||||
|
@ -2981,11 +2936,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Perform a unary minus operation.
|
* Perform a unary minus operation.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_UMINUS:
|
case PH7_OP_UMINUS:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force a numeric (integer,real or both) cast */
|
/* Force a numeric (integer,real or both) cast */
|
||||||
PH7_MemObjToNumeric(pTos);
|
PH7_MemObjToNumeric(pTos);
|
||||||
if(pTos->nType & MEMOBJ_REAL) {
|
if(pTos->nType & MEMOBJ_REAL) {
|
||||||
|
@ -3001,11 +2954,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* Perform a unary plus operation.
|
* Perform a unary plus operation.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_UPLUS:
|
case PH7_OP_UPLUS:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force a numeric (integer,real or both) cast */
|
/* Force a numeric (integer,real or both) cast */
|
||||||
PH7_MemObjToNumeric(pTos);
|
PH7_MemObjToNumeric(pTos);
|
||||||
if(pTos->nType & MEMOBJ_REAL) {
|
if(pTos->nType & MEMOBJ_REAL) {
|
||||||
|
@ -3022,11 +2973,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* with its complement.
|
* with its complement.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_LNOT:
|
case PH7_OP_LNOT:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force a boolean cast */
|
/* Force a boolean cast */
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
|
@ -3040,11 +2989,9 @@ static sxi32 VmByteCodeExec(
|
||||||
* with its ones-complement.
|
* with its ones-complement.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_BITNOT:
|
case PH7_OP_BITNOT:
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force an integer cast */
|
/* Force an integer cast */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3061,11 +3008,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_MUL_STORE: {
|
case PH7_OP_MUL_STORE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
/* Force the operand to be numeric */
|
/* Force the operand to be numeric */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PH7_MemObjToNumeric(pTos);
|
PH7_MemObjToNumeric(pTos);
|
||||||
PH7_MemObjToNumeric(pNos);
|
PH7_MemObjToNumeric(pNos);
|
||||||
/* Perform the requested operation */
|
/* Perform the requested operation */
|
||||||
|
@ -3117,11 +3062,9 @@ static sxi32 VmByteCodeExec(
|
||||||
} else {
|
} else {
|
||||||
pNos = &pTos[-pInstr->iP1 + 1];
|
pNos = &pTos[-pInstr->iP1 + 1];
|
||||||
}
|
}
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pInstr->iP2 || pNos->nType & MEMOBJ_STRING || pTos->nType & MEMOBJ_STRING) {
|
if(pInstr->iP2 || pNos->nType & MEMOBJ_STRING || pTos->nType & MEMOBJ_STRING) {
|
||||||
/* Perform the string addition */
|
/* Perform the string addition */
|
||||||
ph7_value *pCur;
|
ph7_value *pCur;
|
||||||
|
@ -3156,11 +3099,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_ADD_STORE: {
|
case PH7_OP_ADD_STORE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pTos->nType & MEMOBJ_STRING) {
|
if(pTos->nType & MEMOBJ_STRING) {
|
||||||
/* Perform the string addition */
|
/* Perform the string addition */
|
||||||
if((pNos->nType & MEMOBJ_STRING) == 0) {
|
if((pNos->nType & MEMOBJ_STRING) == 0) {
|
||||||
|
@ -3194,11 +3135,9 @@ static sxi32 VmByteCodeExec(
|
||||||
*/
|
*/
|
||||||
case PH7_OP_SUB: {
|
case PH7_OP_SUB: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(MEMOBJ_REAL & (pTos->nType | pNos->nType)) {
|
if(MEMOBJ_REAL & (pTos->nType | pNos->nType)) {
|
||||||
/* Floating point arithemic */
|
/* Floating point arithemic */
|
||||||
ph7_real a, b, r;
|
ph7_real a, b, r;
|
||||||
|
@ -3236,11 +3175,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_SUB_STORE: {
|
case PH7_OP_SUB_STORE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(MEMOBJ_REAL & (pTos->nType | pNos->nType)) {
|
if(MEMOBJ_REAL & (pTos->nType | pNos->nType)) {
|
||||||
/* Floating point arithemic */
|
/* Floating point arithemic */
|
||||||
ph7_real a, b, r;
|
ph7_real a, b, r;
|
||||||
|
@ -3286,11 +3223,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_MOD: {
|
case PH7_OP_MOD: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi64 a, b, r;
|
sxi64 a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3326,11 +3261,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxi64 a, b, r;
|
sxi64 a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3369,11 +3302,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_DIV: {
|
case PH7_OP_DIV: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_real a, b, r;
|
ph7_real a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be real */
|
/* Force the operands to be real */
|
||||||
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
||||||
PH7_MemObjToReal(pTos);
|
PH7_MemObjToReal(pTos);
|
||||||
|
@ -3407,11 +3338,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
ph7_real a, b, r;
|
ph7_real a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be real */
|
/* Force the operands to be real */
|
||||||
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
if((pTos->nType & MEMOBJ_REAL) == 0) {
|
||||||
PH7_MemObjToReal(pTos);
|
PH7_MemObjToReal(pTos);
|
||||||
|
@ -3462,11 +3391,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_BXOR: {
|
case PH7_OP_BXOR: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi64 a, b, r;
|
sxi64 a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3522,11 +3449,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxi64 a, b, r;
|
sxi64 a, b, r;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3582,11 +3507,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi64 a, r;
|
sxi64 a, r;
|
||||||
sxi32 b;
|
sxi32 b;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3628,11 +3551,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxi64 a, r;
|
sxi64 a, r;
|
||||||
sxi32 b;
|
sxi32 b;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force the operands to be integer */
|
/* Force the operands to be integer */
|
||||||
if((pTos->nType & MEMOBJ_INT) == 0) {
|
if((pTos->nType & MEMOBJ_INT) == 0) {
|
||||||
PH7_MemObjToInteger(pTos);
|
PH7_MemObjToInteger(pTos);
|
||||||
|
@ -3675,11 +3596,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_LOR: {
|
case PH7_OP_LOR: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi32 v1, v2; /* 0==TRUE, 1==FALSE, 2==UNKNOWN or NULL */
|
sxi32 v1, v2; /* 0==TRUE, 1==FALSE, 2==UNKNOWN or NULL */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force a boolean cast */
|
/* Force a boolean cast */
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
|
@ -3716,11 +3635,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_LXOR: {
|
case PH7_OP_LXOR: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
sxi32 v = 0;
|
sxi32 v = 0;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Force a boolean cast */
|
/* Force a boolean cast */
|
||||||
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
if((pTos->nType & MEMOBJ_BOOL) == 0) {
|
||||||
PH7_MemObjToBool(pTos);
|
PH7_MemObjToBool(pTos);
|
||||||
|
@ -3754,11 +3671,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_NEQ: {
|
case PH7_OP_NEQ: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
/* Perform the comparison and act accordingly */
|
/* Perform the comparison and act accordingly */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
||||||
if(pInstr->iOp == PH7_OP_EQ) {
|
if(pInstr->iOp == PH7_OP_EQ) {
|
||||||
rc = rc == 0;
|
rc = rc == 0;
|
||||||
|
@ -3803,11 +3718,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_LE: {
|
case PH7_OP_LE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
/* Perform the comparison and act accordingly */
|
/* Perform the comparison and act accordingly */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
||||||
if(pInstr->iOp == PH7_OP_LE) {
|
if(pInstr->iOp == PH7_OP_LE) {
|
||||||
rc = rc < 1;
|
rc = rc < 1;
|
||||||
|
@ -3852,11 +3765,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_GE: {
|
case PH7_OP_GE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
/* Perform the comparison and act accordingly */
|
/* Perform the comparison and act accordingly */
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
rc = PH7_MemObjCmp(pNos, pTos, FALSE, 0);
|
||||||
if(pInstr->iOp == PH7_OP_GE) {
|
if(pInstr->iOp == PH7_OP_GE) {
|
||||||
rc = rc >= 0;
|
rc = rc >= 0;
|
||||||
|
@ -3948,11 +3859,9 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_THROW: {
|
case PH7_OP_THROW: {
|
||||||
VmFrame *pFrame = pVm->pFrame;
|
VmFrame *pFrame = pVm->pFrame;
|
||||||
sxu32 nJump = pInstr->iP2;
|
sxu32 nJump = pInstr->iP2;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
||||||
/* Safely ignore the exception frame */
|
/* Safely ignore the exception frame */
|
||||||
pFrame = pFrame->pParent;
|
pFrame = pFrame->pParent;
|
||||||
|
@ -4081,11 +3990,9 @@ static sxi32 VmByteCodeExec(
|
||||||
*/
|
*/
|
||||||
case PH7_OP_FOREACH_INIT: {
|
case PH7_OP_FOREACH_INIT: {
|
||||||
ph7_foreach_info *pInfo = (ph7_foreach_info *)pInstr->p3;
|
ph7_foreach_info *pInfo = (ph7_foreach_info *)pInstr->p3;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Make sure we are dealing with an array or an object */
|
/* Make sure we are dealing with an array or an object */
|
||||||
if((pTos->nType & MEMOBJ_HASHMAP) == 0 || SyStringLength(&pInfo->sValue) < 1) {
|
if((pTos->nType & MEMOBJ_HASHMAP) == 0 || SyStringLength(&pInfo->sValue) < 1) {
|
||||||
/* Jump out of the loop */
|
/* Jump out of the loop */
|
||||||
|
@ -4163,11 +4070,9 @@ static sxi32 VmByteCodeExec(
|
||||||
SyString sName;
|
SyString sName;
|
||||||
if(!pInstr->iP1) {
|
if(!pInstr->iP1) {
|
||||||
pNos = &pTos[-1];
|
pNos = &pTos[-1];
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(pNos->nType & MEMOBJ_OBJ) {
|
if(pNos->nType & MEMOBJ_OBJ) {
|
||||||
if(!pNos->x.pOther) {
|
if(!pNos->x.pOther) {
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-instantiated object '$%z'", &sName);
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-instantiated object '$%z'", &sName);
|
||||||
|
@ -4320,11 +4225,9 @@ static sxi32 VmByteCodeExec(
|
||||||
if(!pInstr->p3) {
|
if(!pInstr->p3) {
|
||||||
SyStringInitFromBuf(&sName, (const char *)SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
|
SyStringInitFromBuf(&sName, (const char *)SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
|
||||||
pNos--;
|
pNos--;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
/* Attribute name already computed */
|
/* Attribute name already computed */
|
||||||
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
|
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
|
||||||
|
@ -4503,11 +4406,9 @@ static sxi32 VmByteCodeExec(
|
||||||
*/
|
*/
|
||||||
case PH7_OP_CLONE: {
|
case PH7_OP_CLONE: {
|
||||||
ph7_class_instance *pSrc, *pClone;
|
ph7_class_instance *pSrc, *pClone;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Make sure we are dealing with a class instance */
|
/* Make sure we are dealing with a class instance */
|
||||||
if((pTos->nType & MEMOBJ_OBJ) == 0 || pTos->x.pOther == 0) {
|
if((pTos->nType & MEMOBJ_OBJ) == 0 || pTos->x.pOther == 0) {
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||||
|
@ -4536,11 +4437,9 @@ static sxi32 VmByteCodeExec(
|
||||||
ph7_case_expr *aCase, *pCase;
|
ph7_case_expr *aCase, *pCase;
|
||||||
ph7_value sValue, sCaseValue;
|
ph7_value sValue, sCaseValue;
|
||||||
sxu32 n, nEntry;
|
sxu32 n, nEntry;
|
||||||
#ifdef UNTRUST
|
|
||||||
if(pSwitch == 0 || pTos < pStack) {
|
if(pSwitch == 0 || pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Point to the case table */
|
/* Point to the case table */
|
||||||
aCase = (ph7_case_expr *)SySetBasePtr(&pSwitch->aCaseExpr);
|
aCase = (ph7_case_expr *)SySetBasePtr(&pSwitch->aCaseExpr);
|
||||||
nEntry = SySetUsed(&pSwitch->aCaseExpr);
|
nEntry = SySetUsed(&pSwitch->aCaseExpr);
|
||||||
|
|
|
@ -228,11 +228,9 @@ typedef union SyMemHeader SyMemHeader;
|
||||||
typedef struct SyMemBlock SyMemBlock;
|
typedef struct SyMemBlock SyMemBlock;
|
||||||
struct SyMemBlock {
|
struct SyMemBlock {
|
||||||
SyMemBlock *pNext, *pPrev; /* Chain of allocated memory blocks */
|
SyMemBlock *pNext, *pPrev; /* Chain of allocated memory blocks */
|
||||||
#ifdef UNTRUST
|
|
||||||
sxu32 nGuard; /* magic number associated with each valid block,so we
|
sxu32 nGuard; /* magic number associated with each valid block,so we
|
||||||
* can detect misuse.
|
* can detect misuse.
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* Header associated with each valid memory pool block.
|
* Header associated with each valid memory pool block.
|
||||||
|
|
Loading…
Reference in New Issue