mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2025-02-21 12:51:01 +00:00
hnp安装存在签名文件数量统计翻转的问题
Signed-off-by: 王达 <wangda20@huawei.com>
This commit is contained in:
parent
ae7deb82dd
commit
01b31d1e53
@ -18,6 +18,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -264,7 +265,7 @@ int GetRealPath(char *srcPath, char *realPath);
|
||||
int HnpZip(const char *inputDir, zipFile zf);
|
||||
|
||||
int HnpUnZip(const char *inputFile, const char *outputDir, const char *hnpSignKeyPrefix,
|
||||
HnpSignMapInfo *hnpSignMapInfos, int *count);
|
||||
HnpSignMapInfo *hnpSignMapInfos, uint64_t *count);
|
||||
|
||||
int HnpAddFileToZip(zipFile zf, char *filename, char *buff, int size);
|
||||
|
||||
@ -297,7 +298,7 @@ int HnpPackageInfoDelete(const char *packageName);
|
||||
|
||||
char *HnpCurrentVersionUninstallCheck(const char *name);
|
||||
|
||||
int HnpFileCountGet(const char *path, int *count);
|
||||
int HnpFileCountGet(const char *path, uint64_t *count);
|
||||
|
||||
int HnpPathFileCount(const char *path);
|
||||
|
||||
|
@ -362,10 +362,10 @@ static bool HnpELFFileCheck(const char *path)
|
||||
}
|
||||
|
||||
static int HnpInstallAddSignMap(const char* hnpSignKeyPrefix, const char *key, const char *value,
|
||||
HnpSignMapInfo *hnpSignMapInfos, int *count)
|
||||
HnpSignMapInfo *hnpSignMapInfos, uint64_t *count)
|
||||
{
|
||||
int ret;
|
||||
int sum = *count;
|
||||
uint64_t sum = *count;
|
||||
|
||||
if (HnpELFFileCheck(value) == false) {
|
||||
return 0;
|
||||
@ -387,9 +387,9 @@ static int HnpInstallAddSignMap(const char* hnpSignKeyPrefix, const char *key, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HnpFileCountGet(const char *path, int *count)
|
||||
int HnpFileCountGet(const char *path, uint64_t *count)
|
||||
{
|
||||
int sum = 0;
|
||||
uint64_t sum = 0;
|
||||
|
||||
unzFile zipFile = unzOpen(path);
|
||||
if (zipFile == NULL) {
|
||||
@ -416,7 +416,7 @@ int HnpFileCountGet(const char *path, int *count)
|
||||
}
|
||||
|
||||
int HnpUnZip(const char *inputFile, const char *outputDir, const char *hnpSignKeyPrefix,
|
||||
HnpSignMapInfo *hnpSignMapInfos, int *count)
|
||||
HnpSignMapInfo *hnpSignMapInfos, uint64_t *count)
|
||||
{
|
||||
char fileName[MAX_FILE_PATH_LEN];
|
||||
unz_file_info fileInfo;
|
||||
|
@ -43,6 +43,9 @@ extern "C" {
|
||||
// 0x801307 restorecon 安装目录失败
|
||||
#define HNP_ERRNO_INSTALLER_RESTORECON_HNP_PATH_FAIL HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x7)
|
||||
|
||||
// 0x801308 安装包中的二进制文件过多
|
||||
#define HNP_ERRNO_INSTALLER_HAP_FILE_COUNT_OVER HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x8)
|
||||
|
||||
#define HNP_DEFAULT_INSTALL_ROOT_PATH "/data/app/el1/bundle"
|
||||
#define HNP_SANDBOX_BASE_PATH "/data/service/hnp"
|
||||
|
||||
|
@ -183,7 +183,7 @@ static int HnpGenerateSoftLink(const char *installPath, const char *hnpBasePath,
|
||||
}
|
||||
|
||||
static int HnpInstall(const char *hnpFile, HnpInstallInfo *hnpInfo, HnpCfgInfo *hnpCfg,
|
||||
HnpSignMapInfo *hnpSignMapInfos, int *count)
|
||||
HnpSignMapInfo *hnpSignMapInfos, uint64_t *count)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -401,7 +401,7 @@ static int HnpPublicDealAfterInstall(HnpInstallInfo *hnpInfo, HnpCfgInfo *hnpCfg
|
||||
return HnpInstallInfoJsonWrite(hnpInfo->hapInstallInfo->hapPackageName, hnpCfg);
|
||||
}
|
||||
|
||||
static int HnpReadAndInstall(char *srcFile, HnpInstallInfo *hnpInfo, HnpSignMapInfo *hnpSignMapInfos, int *count)
|
||||
static int HnpReadAndInstall(char *srcFile, HnpInstallInfo *hnpInfo, HnpSignMapInfo *hnpSignMapInfos, uint64_t *count)
|
||||
{
|
||||
int ret;
|
||||
HnpCfgInfo hnpCfg = {0};
|
||||
@ -481,7 +481,7 @@ static bool HnpFileCheck(const char *file)
|
||||
}
|
||||
|
||||
static int HnpPackageGetAndInstall(const char *dirPath, HnpInstallInfo *hnpInfo, char *sunDir,
|
||||
HnpSignMapInfo *hnpSignMapInfos, int *count)
|
||||
HnpSignMapInfo *hnpSignMapInfos, uint64_t *count)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
@ -537,7 +537,7 @@ static int HnpPackageGetAndInstall(const char *dirPath, HnpInstallInfo *hnpInfo,
|
||||
}
|
||||
|
||||
static int HapReadAndInstall(const char *dstPath, HapInstallInfo *installInfo, HnpSignMapInfo *hnpSignMapInfos,
|
||||
int *count)
|
||||
uint64_t *count)
|
||||
{
|
||||
struct dirent *entry;
|
||||
char hnpPath[MAX_FILE_PATH_LEN];
|
||||
@ -585,7 +585,7 @@ static int HapReadAndInstall(const char *dstPath, HapInstallInfo *installInfo, H
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int HnpInstallHnpFileCountGet(char *hnpPath, int *count)
|
||||
static int HnpInstallHnpFileCountGet(char *hnpPath, uint64_t *count)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
@ -636,7 +636,7 @@ static int HnpInstallHnpFileCountGet(char *hnpPath, int *count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int HnpInstallHapFileCountGet(const char *root, int *count)
|
||||
static int HnpInstallHapFileCountGet(const char *root, uint64_t *count)
|
||||
{
|
||||
struct dirent *entry;
|
||||
char hnpPath[MAX_FILE_PATH_LEN];
|
||||
@ -714,11 +714,11 @@ static int CheckInstallPath(char *dstPath, HapInstallInfo *installInfo)
|
||||
static int HnpInsatllPre(HapInstallInfo *installInfo)
|
||||
{
|
||||
char dstPath[MAX_FILE_PATH_LEN];
|
||||
int count = 0;
|
||||
uint64_t count = 0;
|
||||
HnpSignMapInfo *hnpSignMapInfos = NULL;
|
||||
#ifdef CODE_SIGNATURE_ENABLE
|
||||
struct EntryMapEntryData data = {0};
|
||||
int i;
|
||||
uint64_t i;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
@ -727,7 +727,9 @@ static int HnpInsatllPre(HapInstallInfo *installInfo)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
if (count >= INT32_MAX) {
|
||||
return HNP_ERRNO_INSTALLER_HAP_FILE_COUNT_OVER;
|
||||
} else if (count > 0) {
|
||||
hnpSignMapInfos = (HnpSignMapInfo *)malloc(sizeof(HnpSignMapInfo) * count);
|
||||
if (hnpSignMapInfos == NULL) {
|
||||
return HNP_ERRNO_NOMEM;
|
||||
@ -736,8 +738,8 @@ static int HnpInsatllPre(HapInstallInfo *installInfo)
|
||||
|
||||
count = 0;
|
||||
ret = HapReadAndInstall(dstPath, installInfo, hnpSignMapInfos, &count);
|
||||
HNP_LOGI("sign start hap path[%{public}s],abi[%{public}s],count=%{public}d", installInfo->hapPath, installInfo->abi,
|
||||
count);
|
||||
HNP_LOGI("sign start hap path[%{public}s],abi[%{public}s],count=%{public}d", installInfo->hapPath,
|
||||
installInfo->abi, (int)count);
|
||||
#ifdef CODE_SIGNATURE_ENABLE
|
||||
if ((ret == 0) && (count > 0)) {
|
||||
data.entries = malloc(sizeof(struct EntryMapEntry) * count);
|
||||
@ -749,7 +751,7 @@ static int HnpInsatllPre(HapInstallInfo *installInfo)
|
||||
data.entries[i].key = hnpSignMapInfos[i].key;
|
||||
data.entries[i].value = hnpSignMapInfos[i].value;
|
||||
}
|
||||
data.count = count;
|
||||
data.count = (uint32_t)count;
|
||||
ret = EnforceCodeSignForApp(installInfo->hapPath, &data, FILE_ENTRY_ONLY);
|
||||
HNP_LOGI("sign end ret=%{public}d,last key[%{public}s],value[%{public}s]", ret, data.entries[i - 1].key,
|
||||
data.entries[i - 1].value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user