if (ret == -1)
{
r = _NativeError::ConvertNativeErrorToResult(errno, true);
- SysTryReturnResult(NID_BASE_UTIL,
+ SysSecureTryReturnResult(NID_BASE_UTIL,
(r == E_SUCCESS) || (r == E_FILE_ALREADY_EXIST), r, "Unable to create directory [%s]", pFilePath);
}
}
SysTryReturnResult(NID_BASE_UTIL, pFilePathBuff != null, E_INVALID_ARG, "Invalid file path.");
const char* pFilePath = reinterpret_cast<const char*> (pFilePathBuff->GetPointer());
- SysTryReturnResult(NID_BASE_UTIL, access(pFilePath, F_OK) == 0, E_FILE_NOT_FOUND, "Invalid file path [%s].", pFilePath);
+ SysSecureTryReturnResult(NID_BASE_UTIL, access(pFilePath, F_OK) == 0, E_FILE_NOT_FOUND, "Invalid file path [%s].", pFilePath);
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(pFilePath));
- SysTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", pFilePath);
+ SysSecureTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", pFilePath);
int dirCount = 0;
int fileCount = 0;
SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_IO, "Failed to get file entry info from the zip file.");
result r = _FileUnzipperImpl::CreateDirectories(outPath);
- SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to create Directory [%s]", outPath);
+ SysSecureTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to create Directory [%s]", outPath);
if(outPath[strlen(outPath) - 1] != '/')
{
std::unique_ptr< FILE, CloseFile > pFile(fopen(outPath, "w"));
r = __ConvertNativeErrorToResult(errno);
- SysTryReturnResult(NID_BASE_UTIL, pFile != null, r, "Failed to open file [name: %s, errorno: %d].", outPath, errno);
+ SysSecureTryReturnResult(NID_BASE_UTIL, pFile != null, r, "Failed to open file [name: %s, errorno: %d].", outPath, errno);
err = unzOpenCurrentFile(pUnZipFile);
SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_IO, "Failed to open current zip file.");
readLen = unzReadCurrentFile(pUnZipFile, writeBuf, sizeof(writeBuf));
r = (readLen < 0) ? E_IO : E_SUCCESS;
SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, unzCloseCurrentFile(pUnZipFile), r,
- "[%s] Failed to read from zip file (%s).", GetErrorMessage(E_IO), outPath);
+ "[%s] Failed to read from zip file.", GetErrorMessage(E_IO));
if (readLen > 0)
{
strncat(outPath, reinterpret_cast<const char*> (pDirBuff->GetPointer()), dirPathLength);
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(__pArchiveName.get()));
- SysTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
+ SysSecureTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
int err = unzGoToFirstFile(pUnzipFile.get());
SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_IO, "Failed to get the first file entry in the zip file.");
const char* pZipEntryName = reinterpret_cast<const char*> (pZipEntryBuff->GetPointer());
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(__pArchiveName.get()));
- SysTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
+ SysSecureTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
int err = unzLocateFile(pUnzipFile.get(), pZipEntryName, UNZ_COMP_CASE_SENSITIVE);
- SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_FILE_NOT_FOUND, "Failed to locate file entry (%s).", pZipEntryName);
+ SysSecureTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_FILE_NOT_FOUND, "Failed to locate file entry (%s).", pZipEntryName);
return UnzipCurrentFileTo(pUnzipFile.get(), outPath, dirPathLength);
}
const char* pZipEntryName = reinterpret_cast<const char*> (pZipEntryBuff->GetPointer());
std::unique_ptr< void, CloseUnzipFile > pZipFile(unzOpen(__pArchiveName.get()));
- SysTryReturnResult(NID_BASE_UTIL, pZipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
+ SysSecureTryReturnResult(NID_BASE_UTIL, pZipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
int err = unzLocateFile(pZipFile.get(), pZipEntryName, UNZ_COMP_CASE_SENSITIVE);
- SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_FILE_NOT_FOUND, "Failed to locate file entry (%s).", pZipEntryName);
+ SysSecureTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_FILE_NOT_FOUND, "Failed to locate file entry (%s).", pZipEntryName);
return GetCurrentFileInfo(pZipFile.get(), entry);
}
SysAssertf(__pArchiveName != null, "Not yet constructed! Construct() should be called before use");
std::unique_ptr< void, CloseUnzipFile > pZipFile(unzOpen(__pArchiveName.get()));
- SysTryReturnResult(NID_BASE_UTIL, pZipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
+ SysSecureTryReturnResult(NID_BASE_UTIL, pZipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
// goto the first file in the archive
int err = unzGoToFirstFile(pZipFile.get());
const char* pFilePath = reinterpret_cast<const char*> (pFilePathBuff->GetPointer());
result r = IsFileExists(pFilePath);
- SysTryReturnResult(NID_BASE_UTIL, (r == E_SUCCESS) || (r == E_FILE_NOT_FOUND), r, "Invalid file path [%s].", pFilePath);
+ SysSecureTryReturnResult(NID_BASE_UTIL, (r == E_SUCCESS) || (r == E_FILE_NOT_FOUND), r, "Invalid file path [%s].", pFilePath);
int createOption = (r == E_FILE_NOT_FOUND)? APPEND_STATUS_CREATE : APPEND_STATUS_ADDINZIP;
std::unique_ptr< void, ZipFileDeleter > pZfile(zipOpen(pFilePath, createOption));
- SysTryReturnResult(NID_BASE_UTIL, pZfile != null, E_IO, "Invalid file path [%s].", pFilePath);
+ SysSecureTryReturnResult(NID_BASE_UTIL, pZfile != null, E_IO, "Invalid file path [%s].", pFilePath);
int len = strlen(pFilePath);
std::unique_ptr< char[] > pArchiveName(new (std::nothrow) char[len + 1]);
result r = E_SUCCESS;
std::unique_ptr< void, ZipFileDeleter > pZfile(zipOpen(__pArchiveName.get(), APPEND_STATUS_ADDINZIP));
- SysTryReturnResult(NID_BASE_UTIL, pZfile != null, E_IO, "Invalid file path [%s].", __pArchiveName.get());
+ SysSecureTryReturnResult(NID_BASE_UTIL, pZfile != null, E_IO, "Invalid file path [%s].", __pArchiveName.get());
zip_fileinfo zipInfo = {{0}};
err = zipOpenNewFileInZip(pZfile.get(), pFilePathForZip, &zipInfo, null, 0, null, 0, null, Z_DEFLATED, level);
if (pFile == null)
{
zipCloseFileInZip(pZfile.get());
- SysTryReturnResult(NID_BASE_UTIL, pFile != null, __ConvertNativeErrorToResult(errno), "[%s] Failed to open the file.");
+ SysTryReturnResult(NID_BASE_UTIL, pFile != null, __ConvertNativeErrorToResult(errno), "Failed to open the file.");
}
int readCnt = 1;