This commit is contained in:
2018-07-23 19:39:21 +02:00
parent c28e0dbc88
commit 52d9616503
7 changed files with 11 additions and 39 deletions

View File

@@ -10648,21 +10648,18 @@ static int VmIsIncludedFile(ph7_vm *pVm, SyString *pFile) {
/*
* Push a file path in the appropriate VM container.
*/
PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, sxu8 bMain, sxi32 *pNew) {
PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, sxu8 bMain, sxi32 *pNew) {
SyString sPath;
char *fPath[PATH_MAX + 1];
char *zDup;
#ifdef __WINNT__
char *zCur;
#endif
sxi32 nLen;
sxi32 rc;
if(SyRealpath(zPath, fPath) != PH7_OK) {
return SXERR_IO;
if(nLen < 0) {
nLen = SyStrlen(zPath);
}
nLen = SyStrlen(fPath);
/* Duplicate the file path first */
zDup = SyMemBackendStrDup(&pVm->sAllocator, fPath, nLen);
zDup = SyMemBackendStrDup(&pVm->sAllocator, zPath, nLen);
if(zDup == 0) {
return SXERR_MEM;
}
@@ -10724,28 +10721,20 @@ static sxi32 VmExecIncludedFile(
#ifndef PH7_DISABLE_BUILTIN_FUNC
const ph7_io_stream *pStream;
SyBlob sContents;
SyString zPath;
void *pHandle;
ph7_vm *pVm;
char fPath[PATH_MAX + 1];
int isNew;
sxi32 nLen;
/* Initialize fields */
pVm = pCtx->pVm;
SyBlobInit(&sContents, &pVm->sAllocator);
isNew = 0;
/* Extract the associated stream */
if(SyRealpath(pPath->zString, fPath) != PH7_OK) {
return SXERR_IO;
}
nLen = SyStrlen(fPath);
SyStringInitFromBuf(&zPath, fPath, nLen);
pStream = PH7_VmGetStreamDevice(pVm, &zPath.zString, zPath.nByte);
pStream = PH7_VmGetStreamDevice(pVm, &pPath->zString, pPath->nByte);
/*
* Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"]
* in a read-only mode.
*/
pHandle = PH7_StreamOpenHandle(pVm, pStream, zPath.zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew);
pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew);
if(pHandle == 0) {
return SXERR_IO;
}