diff --git a/interfaces/innerkits/appverify_lite/products/ipcamera/app_verify_base.h b/interfaces/innerkits/appverify_lite/products/ipcamera/app_verify_base.h index 4b32c1c1e9a9c63c3fac9708e4db68c2b0554e45..8e6bfec4303a5f1667a4c3b3bac0764557044804 100644 --- a/interfaces/innerkits/appverify_lite/products/ipcamera/app_verify_base.h +++ b/interfaces/innerkits/appverify_lite/products/ipcamera/app_verify_base.h @@ -29,11 +29,11 @@ extern "C" { #undef LOG_DOMAIN #define LOG_DOMAIN 0xD001100 -#define LOG_INFO(fmt, args...) HILOG_INFO(LOG_DOMAIN, "[%s:%d]: "fmt, __FUNCTION__, __LINE__, ##args) -#define LOG_DEBUG(fmt, args...) HILOG_DEBUG(LOG_DOMAIN, "[%s:%d]: "fmt, __FUNCTION__, __LINE__, ##args) -#define LOG_WARN(fmt, args...) HILOG_WARN(LOG_DOMAIN, "[%s:%d]: "fmt, __FUNCTION__, __LINE__, ##args) -#define LOG_ERROR(fmt, args...) HILOG_ERROR(LOG_DOMAIN, "[%s:%d]: "fmt, __FUNCTION__, __LINE__, ##args) -#define LOG_PRINT_STR(fmt, args...) HILOG_INFO(LOG_DOMAIN, "[%s:%d]: "fmt, __FUNCTION__, __LINE__, ##args) +#define LOG_INFO(fmt, args...) HILOG_INFO(LOG_DOMAIN, "[%s:%{public}d]: "fmt, __FUNCTION__, __LINE__, ##args) +#define LOG_DEBUG(fmt, args...) HILOG_DEBUG(LOG_DOMAIN, "[%s:%{public}d]: "fmt, __FUNCTION__, __LINE__, ##args) +#define LOG_WARN(fmt, args...) HILOG_WARN(LOG_DOMAIN, "[%s:%{public}d]: "fmt, __FUNCTION__, __LINE__, ##args) +#define LOG_ERROR(fmt, args...) HILOG_ERROR(LOG_DOMAIN, "[%s:%{public}d]: "fmt, __FUNCTION__, __LINE__, ##args) +#define LOG_PRINT_STR(fmt, args...) HILOG_INFO(LOG_DOMAIN, "[%s:%{public}d]: "fmt, __FUNCTION__, __LINE__, ##args) void RegistProductFunc(ProductDiff *productFunc); #ifdef __cplusplus diff --git a/interfaces/innerkits/appverify_lite/src/app_centraldirectory.c b/interfaces/innerkits/appverify_lite/src/app_centraldirectory.c index fbd08c9486f5d7e3951a44da198396bf8fd116fc..5a2b73ba599c8bd7cf0c7defda71003fad9a3914 100644 --- a/interfaces/innerkits/appverify_lite/src/app_centraldirectory.c +++ b/interfaces/innerkits/appverify_lite/src/app_centraldirectory.c @@ -55,7 +55,7 @@ void HapPutData(const HapBuf *hapBuffer, int32_t offset, const unsigned char *da void HapSetInt32(const HapBuf *buffer, int32_t offset, int32_t value) { if (value < 0) { - LOG_ERROR("int32 value of out range: %d", value); + LOG_ERROR("int32 value of out range: %{public}d", value); return; } if (buffer == NULL || buffer->buffer == NULL) { @@ -121,7 +121,7 @@ static bool GetEocd(const FileRead *hapFile, HapEocd *hapEocd, int32_t *eocdOffs int32_t maxReadLen = ((unsigned int)(hapFile->len - sizeof(MinEocd)) > UINT16_MAX_VALUE) ? UINT16_MAX_VALUE : (hapFile->len - sizeof(MinEocd)); fileStart += hapFile->len - sizeof(MinEocd) - maxReadLen; - LOG_INFO("maxReadLen %d", maxReadLen); + LOG_INFO("maxReadLen %{public}d", maxReadLen); for (int32_t i = 0; i < maxReadLen; i++) { if ((HapGetShort((unsigned char*)fileStart + i + sizeof(MinEocd) - sizeof(short), sizeof(short)) == (maxReadLen - i)) && @@ -133,7 +133,7 @@ static bool GetEocd(const FileRead *hapFile, HapEocd *hapEocd, int32_t *eocdOffs return false; } HapMUnMap(mmapInfo.mapAddr, mmapInfo.mmapSize); - LOG_INFO("comment num %d", maxReadLen - i); + LOG_INFO("comment num %{public}d", maxReadLen - i); *eocdOffset = hapFile->len - sizeof(MinEocd) - (maxReadLen - i); return true; } @@ -176,7 +176,7 @@ int32_t ReadFileFullyFromOffset(const HapBuf *buffer, int32_t offset, const File lseek(file->fp, offset, SEEK_SET); int32_t readLen = read(file->fp, buffer->buffer, buffer->len); if (readLen != buffer->len) { - LOG_ERROR("file read error %d --- %d", readLen, buffer->len); + LOG_ERROR("file read error %{public}d --- %{public}d", readLen, buffer->len); return READ_OFFSET_OUT_OF_RANGE; } return buffer->len; diff --git a/interfaces/innerkits/appverify_lite/src/app_file.c b/interfaces/innerkits/appverify_lite/src/app_file.c index e71def56d5b4394c06d23eeb53d93cafe0aba0df..a314400154516363e63f57396ae0f95e9203b11c 100644 --- a/interfaces/innerkits/appverify_lite/src/app_file.c +++ b/interfaces/innerkits/appverify_lite/src/app_file.c @@ -53,7 +53,7 @@ int32_t InitVerify(FileRead *file, const char *filePath, int32_t *handle) g_memoryPageSize = sysconf(_SC_PAGESIZE); } if (g_memoryPageSize <= 0) { - LOG_ERROR("MAP_FAILED %d", g_memoryPageSize); + LOG_ERROR("MAP_FAILED %{public}d", g_memoryPageSize); APPV_FREE(path); return V_ERR_FILE_STAT; } diff --git a/interfaces/innerkits/appverify_lite/src/app_provision.c b/interfaces/innerkits/appverify_lite/src/app_provision.c index 598f5d9fc034730119479c65fb035154f9009daa..4cee147fe445244275ca8f35b4d8e5b7069d11ab 100644 --- a/interfaces/innerkits/appverify_lite/src/app_provision.c +++ b/interfaces/innerkits/appverify_lite/src/app_provision.c @@ -52,13 +52,13 @@ static char *GetStringTag(const cJSON *root, const char *tag) } char *value = APPV_MALLOC(objLen + 1); if (value == NULL) { - LOG_ERROR("malloc error: %d", objLen + 1); + LOG_ERROR("malloc error: %{public}d", objLen + 1); return NULL; } errno_t ret = strcpy_s(value, objLen + 1, jsonObj->valuestring); if (ret != EOK) { APPV_FREE(value); - LOG_ERROR("strcpy error: %d", ret); + LOG_ERROR("strcpy error: %{public}d", ret); return NULL; } return value; @@ -113,7 +113,7 @@ static char **GetStringArrayTag(const cJSON *root, const char *tag, int32_t *num errno_t ret = strcpy_s(value[i], len + 1, item->valuestring); if (ret != EOK) { - LOG_ERROR("str cpy error : %d", ret); + LOG_ERROR("str cpy error : %{public}d", ret); FreeStringAttay(value, num); return NULL; } @@ -225,7 +225,7 @@ static int32_t GetProfIssuerInfo(const cJSON *root, ProfileProf *pf) errno_t ret = strcpy_s(pf->issuer, len + 1, APP_STORE); if (ret != EOK) { APPV_FREE(pf->issuer); - LOG_ERROR("str cpy error: %d", ret); + LOG_ERROR("str cpy error: %{public}d", ret); } return ret; } @@ -392,7 +392,7 @@ static int32_t VerifyUdid(const ProfileProf *pf) int32_t result = InquiryDeviceUdid(udid, size); if (result != INQUIRY_UDID_OK) { free(udid); - LOG_ERROR("get udid fail, ret: %d", result); + LOG_ERROR("get udid fail, ret: %{public}d", result); return V_ERR; } for (int32_t i = 0; i < pf->debugInfo.devidNum; i++) { diff --git a/interfaces/innerkits/appverify_lite/src/app_verify.c b/interfaces/innerkits/appverify_lite/src/app_verify.c index f84a6f6c871e7af785a087ff9e7698beb0a2c0db..cb38c568aab4a96093a93cccda6ac37269ad789a 100644 --- a/interfaces/innerkits/appverify_lite/src/app_verify.c +++ b/interfaces/innerkits/appverify_lite/src/app_verify.c @@ -118,7 +118,7 @@ static int32_t GetSignHead(const FileRead *file, SignatureInfo *signInfo) struct stat fileSt; int32_t ret = fstat(file->fp, &fileSt); if ((ret != 0) || (fileSt.st_size < sizeof(HwSignHead))) { - LOG_ERROR("fstat error, %d, filelen: %d", ret, (int)fileSt.st_size); + LOG_ERROR("fstat error, %{public}d, filelen: %{public}d", ret, (int)fileSt.st_size); return V_ERR_GET_SIGNHEAD; } if (!FindSignature(file, signInfo)) { @@ -126,19 +126,19 @@ static int32_t GetSignHead(const FileRead *file, SignatureInfo *signInfo) return V_ERR_GET_SIGNHEAD; } if (signInfo->hapCoreDirOffset < sizeof(HwSignHead)) { - LOG_ERROR("hapCoreDirOffset error, %d", signInfo->hapCoreDirOffset); + LOG_ERROR("hapCoreDirOffset error, %{public}d", signInfo->hapCoreDirOffset); return V_ERR_GET_SIGNHEAD; } ret = lseek(file->fp, signInfo->hapCoreDirOffset - sizeof(HwSignHead), SEEK_SET); if (ret < 0) { - LOG_ERROR("lseek error, %d", ret); + LOG_ERROR("lseek error, %{public}d", ret); return V_ERR_GET_SIGNHEAD; } HwSignHead *signHead = APPV_MALLOC(sizeof(HwSignHead)); P_NULL_RETURN_WTTH_LOG(signHead); int32_t readLen = read(file->fp, signHead, sizeof(HwSignHead)); if (readLen != sizeof(HwSignHead)) { - LOG_ERROR("readLen %d, %d", readLen, (int)sizeof(HwSignHead)); + LOG_ERROR("readLen %{public}d, %{public}d", readLen, (int)sizeof(HwSignHead)); APPV_FREE(signHead); return V_ERR_GET_SIGNHEAD; } @@ -178,7 +178,7 @@ static int32_t FindBlockHead(const SignatureInfo *signInfo, int32_t fp, int32_t while (num-- > 0) { int32_t readLen = read(fp, block, sizeof(BlockHead)); if (readLen != sizeof(BlockHead)) { - LOG_ERROR("find block head , read err %d, %d", readLen, (int)sizeof(BlockHead)); + LOG_ERROR("find block head , read err %{public}d, %{public}d", readLen, (int)sizeof(BlockHead)); return V_ERR; } int32_t type = HapGetInt((unsigned char *)&block->type, sizeof(block->type)); @@ -188,7 +188,7 @@ static int32_t FindBlockHead(const SignatureInfo *signInfo, int32_t fp, int32_t return V_OK; } } - LOG_ERROR("get sign block by type failed, type: %d", blockType); + LOG_ERROR("get sign block by type failed, type: %{public}d", blockType); return V_ERR; } @@ -203,7 +203,7 @@ char *GetSignBlockByType( LOG_ERROR("find block head error"); return NULL; } - LOG_INFO("type: %u, len: %u, offset: %u signoffset: %d", + LOG_INFO("type: %u, len: %u, offset: %u signoffset: %{public}d", blockHead->type, blockHead->length, blockHead->offset, signInfo->fullSignBlockOffset); /* sign block head length always 0 rawdata @@ -226,14 +226,14 @@ char *GetSignBlockByType( struct stat fileSt; ret = fstat(fp, &fileSt); if ((ret != 0) || (fileSt.st_size < signInfo->fullSignBlockOffset + blockHead->offset + blockHead->length)) { - LOG_ERROR("fstat error, %d, filelen: %d", ret, (int)fileSt.st_size); + LOG_ERROR("fstat error, %{public}d, filelen: %{public}d", ret, (int)fileSt.st_size); APPV_FREE(buf); return NULL; } lseek(fp, signInfo->fullSignBlockOffset + blockHead->offset, SEEK_SET); int32_t readLen = read(fp, buf, blockHead->length); if (readLen != blockHead->length) { - LOG_ERROR("read error: %d, %d", readLen, blockHead->length); + LOG_ERROR("read error: %{public}d, %{public}d", readLen, blockHead->length); APPV_FREE(buf); return NULL; } @@ -244,7 +244,7 @@ char *GetSignBlockByType( int32_t GetHashUnitLen(int32_t hashAlg) { - LOG_INFO("algId: %d", hashAlg); + LOG_INFO("algId: %{public}d", hashAlg); return mbedtls_md_get_size(mbedtls_md_info_from_type((mbedtls_md_type_t)hashAlg)); } @@ -271,7 +271,7 @@ static int32_t CalcCmpContHash(const Pkcs7 *pkcs7, const SignerInfo *signer, size_t digInAttrLen; rc = PKCS7_GetDigestInSignerAuthAttr((SignerInfo *)signer, &digInAttr, &digInAttrLen); if (rc != V_OK) { - LOG_ERROR("PKCS7_GetDigestInSignerAuthAttr error: %d", rc); + LOG_ERROR("PKCS7_GetDigestInSignerAuthAttr error: %{public}d", rc); return rc; } if (digInAttrLen != *hashLen) { @@ -301,12 +301,12 @@ static int32_t CalcDigest(const Pkcs7 *pkcs7, const SignerInfo *signer, /* calc the attribute hash */ rc = PKCS7_GetSignerAuthAttr(signer, &input, &inputLen); if (rc != V_OK) { - LOG_ERROR("Error: PKCS7_GetSignerAuthAttr failed ret: %d", rc); + LOG_ERROR("Error: PKCS7_GetSignerAuthAttr failed ret: %{public}d", rc); return rc; } rc = mbedtls_md(mbedtls_md_info_from_type(algType), input, inputLen, hash); if (rc != V_OK) { - LOG_ERROR("Error: calc digest failed ret: %d", rc); + LOG_ERROR("Error: calc digest failed ret: %{public}d", rc); return rc; } *hashLen = mbedtls_md_get_size(mbedtls_md_info_from_type(algType)); @@ -321,17 +321,17 @@ static int32_t VerifyRawHash(const SignatureInfo *signInfo, const FileRead *file /* calc orinal context hash */ int32_t ret = PKCS7_GetContentData((Pkcs7 *)pkcs7Handle, &input, &inputLen); if (ret != V_OK) { - LOG_ERROR("get content info error: %d", ret); + LOG_ERROR("get content info error: %{public}d", ret); return ret; } - LOG_INFO("content: len: %d", (int)inputLen); + LOG_INFO("content: len: %{public}d", (int)inputLen); ContentInfo *content = APPV_MALLOC(sizeof(ContentInfo)); P_NULL_RETURN_WTTH_LOG(content); ret = memcpy_s(content, sizeof(ContentInfo), input, inputLen); if (ret != EOK) { - LOG_ERROR("mem cpy error, ret: %d", ret); + LOG_ERROR("mem cpy error, ret: %{public}d", ret); APPV_FREE(content); return ret; } @@ -409,7 +409,7 @@ static int32_t GetProfileCertTypeBySignInfo(SignerResovledInfo *signer, int32_t } /* check level */ if (trustCert != NULL && trustCert->maxCertPath < signer->depth) { - LOG_ERROR("cert maxdepth error: %d", signer->depth); + LOG_ERROR("cert maxdepth error: %{public}d", signer->depth); return V_ERR; } *certType = GetCertTypeBySourceName(trustCert); @@ -440,7 +440,7 @@ static int32_t GetAppCertTypeBySignInfo(SignerResovledInfo *signer, int32_t *cer } /* check level */ if (trustCert != NULL && trustCert->maxCertPath < signer->depth) { - LOG_ERROR("cert maxdepth error: %d %d", trustCert->maxCertPath, signer->depth); + LOG_ERROR("cert maxdepth error: %{public}d %{public}d", trustCert->maxCertPath, signer->depth); return V_ERR; } *certType = GetCertTypeBySourceName(trustCert); @@ -458,7 +458,7 @@ static int32_t GetAppSingerCertType(Pkcs7 *pkcs7Handle, int32_t *certType) } int32_t ret = GetAppCertTypeBySignInfo(&sri->signers[0], certType); if (ret != V_OK) { - LOG_ERROR("get cert type by sign info failed: %d", ret); + LOG_ERROR("get cert type by sign info failed: %{public}d", ret); PKCS7_FreeAllSignersResolvedInfo(sri); return V_ERR; } @@ -476,7 +476,7 @@ static int32_t GetProfileSingerCertType(Pkcs7 *pkcs7Handle, int32_t *certType) } int32_t ret = GetProfileCertTypeBySignInfo(&sri->signers[0], certType); if (ret != V_OK) { - LOG_ERROR("get cert type by sign info failed: %d", ret); + LOG_ERROR("get cert type by sign info failed: %{public}d", ret); PKCS7_FreeAllSignersResolvedInfo(sri); return V_ERR; } @@ -562,7 +562,7 @@ static unsigned char *GetRsaPk(const mbedtls_pk_context *pk, int32_t *len) } unsigned char *c = buf + MAX_PK_BUF; int32_t pkLen = mbedtls_pk_write_pubkey(&c, buf, pk); - LOG_INFO("GetRsaPk pkLen %d", pkLen); + LOG_INFO("GetRsaPk pkLen %{public}d", pkLen); if (pkLen < 0 || pkLen > MAX_PK_BUF) { LOG_ERROR("get pk buf error"); (void)memset_s(buf, MAX_PK_BUF, 0, MAX_PK_BUF); @@ -578,7 +578,7 @@ static unsigned char *GetRsaPk(const mbedtls_pk_context *pk, int32_t *len) } ret = memcpy_s(pkBuf, pkLen, c, pkLen); if (ret != EOK) { - LOG_ERROR("mem copy error: %d", ret); + LOG_ERROR("mem copy error: %{public}d", ret); (void)memset_s(buf, MAX_PK_BUF, 0, MAX_PK_BUF); APPV_FREE(buf); APPV_FREE(pkBuf); @@ -616,7 +616,7 @@ static unsigned char *GetEcPk(const mbedtls_pk_context *pk, int32_t *len) APPV_FREE(buf); return NULL; } - LOG_INFO("GetEcPk *len %d", *len); + LOG_INFO("GetEcPk *len %{public}d", *len); if (*len <= 0 || *len > MBEDTLS_ECP_MAX_PT_LEN) { APPV_FREE(buf); return NULL; @@ -630,7 +630,7 @@ static unsigned char *GetEcPk(const mbedtls_pk_context *pk, int32_t *len) } ret = memcpy_s(pkBuf, *len, buf, *len); if (ret != EOK) { - LOG_ERROR("mem copy error: %d", ret); + LOG_ERROR("mem copy error: %{public}d", ret); (void)memset_s(buf, MBEDTLS_ECP_MAX_PT_LEN, 0, MBEDTLS_ECP_MAX_PT_LEN); APPV_FREE(buf); APPV_FREE(pkBuf); @@ -659,7 +659,7 @@ static int32_t ParseCertGetPk(const char *certEncoded, AppSignPk *pk) mbedtls_x509_crt_init(cert); int32_t ret = mbedtls_x509_crt_parse(cert, (unsigned char *)certEncoded, strlen(certEncoded) + 1); if (ret != V_OK) { - LOG_ERROR("load cert failed, ret: %d", ret); + LOG_ERROR("load cert failed, ret: %{public}d", ret); APPV_FREE(cert); return V_ERR; } @@ -689,7 +689,7 @@ static int32_t GetAppSignPublicKey(const ProfileProf *profile, AppSignPk *pk) ret = ParseCertGetPk((char *)profile->bundleInfo.devCert, pk); } if (ret != V_OK) { - LOG_ERROR("GetSignCertpk failed, ret: %d", ret); + LOG_ERROR("GetSignCertpk failed, ret: %{public}d", ret); return V_ERR_GET_CERT_PK; } return V_OK; @@ -718,7 +718,7 @@ int32_t GetAppid(ProfileProf *profile) int32_t bundleNameLen = strlen(profile->bundleInfo.bundleName); int32_t appidLen = bundleNameLen + useLen + 1 + 1; - LOG_INFO("GetAppid %d", appidLen); + LOG_INFO("GetAppid %{public}d", appidLen); if (useLen > MAX_KEY_PAIR_SIZE) { return V_ERR; } @@ -731,7 +731,7 @@ int32_t GetAppid(ProfileProf *profile) appid[appidLen - 1] = '\0'; ret = snprintf_s(appid, appidLen, bundleNameLen + 1, "%s_", profile->bundleInfo.bundleName); if (ret < 0) { - LOG_ERROR("snprintf error ret: %d", ret); + LOG_ERROR("snprintf error ret: %{public}d", ret); APPV_FREE(appid); FreeAppSignPublicKey(&pk); return V_ERR_GET_APPID; @@ -745,7 +745,7 @@ int32_t GetAppid(ProfileProf *profile) return V_ERR_GET_APPID; } profile->appid = appid; - LOG_INFO("appid len: %d, bL len: %d, base64: %d", appidLen, bundleNameLen, (int)useLen); + LOG_INFO("appid len: %{public}d, bL len: %{public}d, base64: %{public}d", appidLen, bundleNameLen, (int)useLen); LOG_PRINT_STR("%s", appid); FreeAppSignPublicKey(&pk); return V_OK; @@ -760,7 +760,7 @@ static int32_t VerifyProfGetContent(int32_t fp, const SignatureInfo *signInfo, i int32_t rawLen = 0; char *rawBuf = GetSignBlockByType(signInfo, fp, PROFILE_BLOCK_WITHSIGN_TYPE, &rawLen, &blockHead); P_NULL_RETURN_RET_WTTH_LOG(rawBuf, V_ERR_GET_PROFILE_DATA); - LOG_INFO("certType %d", certType); + LOG_INFO("certType %{public}d", certType); /* app gallary with no sign */ if (certType == CERT_TYPE_APPGALLARY) { profBuf = rawBuf; @@ -819,7 +819,7 @@ static int32_t CmpCert(const mbedtls_x509_crt *certA, const CertInfo *binSignCer P_NULL_RETURN_RET_WTTH_LOG(bufA, V_ERR); if (lenA != binSignCert->pkLen) { - LOG_ERROR("pkA len diff %d, %d", lenA, binSignCert->pkLen); + LOG_ERROR("pkA len diff %{public}d, %{public}d", lenA, binSignCert->pkLen); APPV_FREE(bufA); return V_ERR; } @@ -905,7 +905,7 @@ static int32_t CheckAppSignCertWithProfile(int32_t appCertType, CertInfo *binSig { /* cert type appgallary or system, not check */ if (appCertType == CERT_TYPE_APPGALLARY || appCertType == CERT_TYPE_SYETEM) { - LOG_INFO("app type : %d, return OK", appCertType); + LOG_INFO("app type : %{public}d, return OK", appCertType); return V_OK; } @@ -917,7 +917,7 @@ static int32_t CheckAppSignCertWithProfile(int32_t appCertType, CertInfo *binSig ret = CheckReleaseAppSign(binSignCert, pf); } - LOG_INFO("check app sign cert ret : %d", ret); + LOG_INFO("check app sign cert ret : %{public}d", ret); return ret; } @@ -1012,7 +1012,7 @@ static int32_t VerfiyAppSourceGetProfile(int32_t fp, const SignatureInfo *signIn { int32_t ret = VerifyProfGetContent(fp, signInfo, certType, pf); if (ret != V_OK) { - LOG_ERROR("VerifyProfGetContent error: %d", ret); + LOG_ERROR("VerifyProfGetContent error: %{public}d", ret); return ret; } LOG_INFO("verify prof get content success"); @@ -1020,7 +1020,7 @@ static int32_t VerfiyAppSourceGetProfile(int32_t fp, const SignatureInfo *signIn /* verfiy profile cert and app sign cert */ ret = CheckAppSignCertWithProfile(certType, binSignCert, pf); if (ret != V_OK) { - LOG_ERROR("CheckAppSignCertWithProfile error: %d", ret); + LOG_ERROR("CheckAppSignCertWithProfile error: %{public}d", ret); ProfFreeData(pf); return V_ERR_VERFIY_PROF_CERT; } @@ -1038,21 +1038,21 @@ static int32_t VerifyAppSignPkcsData(const FileRead *fileRead, const SignatureIn /* verify sign, rawdata */ int32_t ret = PKCS7_VerifyCertsChain(pkcs7Handle); if (ret != V_OK) { - LOG_ERROR("Verify certs failed, ret: %d", ret); + LOG_ERROR("Verify certs failed, ret: %{public}d", ret); return V_ERR_VERIFY_CERT_CHAIN; } LOG_INFO("Verify certs success"); ret = VerifyRawHash(signInfo, fileRead, pkcs7Handle); if (ret != V_OK) { - LOG_ERROR("VerifyRawHash failed : %d", ret); + LOG_ERROR("VerifyRawHash failed : %{public}d", ret); return ret; } LOG_INFO("VerifyRawHash success"); ret = PKCS7_VerifySignerSignature(pkcs7Handle, CalcDigest); if (ret != V_OK) { - LOG_ERROR("pkcs7 verify signer signature failed : %d", ret); + LOG_ERROR("pkcs7 verify signer signature failed : %{public}d", ret); return V_ERR_VERIFY_SIGNATURE; } @@ -1068,7 +1068,7 @@ static Pkcs7 *GetBinSignPkcs(const char *signBuf, int32_t len) } int32_t ret = PKCS7_ParseSignedData((unsigned char *)signBuf, (size_t)len, pkcs7); if (ret != V_OK) { - LOG_ERROR("pkcs7parse message failed, ret: %d", ret); + LOG_ERROR("pkcs7parse message failed, ret: %{public}d", ret); PKCS7_FreeRes(pkcs7); APPV_FREE(pkcs7); return NULL; @@ -1117,11 +1117,11 @@ static int32_t VerifyBinSign(SignatureInfo *signInfo, int32_t fp, CertInfo **sig } ret = GetAppSingerCertType(pkcs7, certType); if (ret != V_OK) { - LOG_ERROR("cert source invalid: %d", ret); + LOG_ERROR("cert source invalid: %{public}d", ret); ret = V_ERR_GET_CERT_TYPE; goto EXIT; } - LOG_INFO("get cert Type : %d", *certType); + LOG_INFO("get cert Type : %{public}d", *certType); signInfo->certType = *certType; ret = VerifyAppSignPkcsData(fileRead, signInfo, pkcs7); if (ret != V_OK) { @@ -1133,7 +1133,7 @@ static int32_t VerifyBinSign(SignatureInfo *signInfo, int32_t fp, CertInfo **sig ret = GetCertInfo(pkcs7->signedData.signers.certPath.crt, signCert); if (ret != V_OK) { - LOG_ERROR("get bin cert info error: %d", ret); + LOG_ERROR("get bin cert info error: %{public}d", ret); ret = V_ERR_GET_CERT_INFO; goto EXIT; } @@ -1161,7 +1161,7 @@ static int32_t VerifyIntegrity(SignatureInfo *signInfo, int32_t fp, ProfileProf ret = VerfiyAppSourceGetProfile(fp, signInfo, certType, binSignCert, pf); if (ret != V_OK) { - LOG_ERROR("verify app source failed : %d", ret); + LOG_ERROR("verify app source failed : %{public}d", ret); FreeCertInfo(binSignCert); APPV_FREE(binSignCert); return ret; @@ -1214,7 +1214,7 @@ int32_t APPVERI_AppVerify(const char *filePath, VerifyResult *verifyRst) APPV_FREE(fileSt); return V_ERR_FILE_STAT; } - LOG_INFO("file len: %d", (int)fileSt->st_size); + LOG_INFO("file len: %{public}d", (int)fileSt->st_size); close(handle); APPV_FREE(signHead); APPV_FREE(fileSt); @@ -1224,7 +1224,7 @@ int32_t APPVERI_AppVerify(const char *filePath, VerifyResult *verifyRst) /* set debug mode */ int32_t APPVERI_SetDebugMode(bool mode) { - LOG_INFO("set debug mode: %d", mode); + LOG_INFO("set debug mode: %{public}d", mode); if (g_isDebugMode == mode) { return V_OK; } diff --git a/interfaces/innerkits/appverify_lite/src/app_verify_hap.c b/interfaces/innerkits/appverify_lite/src/app_verify_hap.c index e39a5340ab3b054e1cc6ebab137b12ba531aab1c..b2ca0ac61b9e4471de21c455d687f6491c35ab41 100644 --- a/interfaces/innerkits/appverify_lite/src/app_verify_hap.c +++ b/interfaces/innerkits/appverify_lite/src/app_verify_hap.c @@ -48,7 +48,7 @@ static int32_t ComputeBlockHash(const char *block, int32_t blockLen, int32_t alg int32_t rawBufLen = blockLen; mbedtls_md_context_t *mdCtx = APPV_MALLOC(sizeof(mbedtls_md_context_t)); P_NULL_RETURN_WTTH_LOG(mdCtx); - LOG_INFO("alg: %d wholelen: %d", alg, rawBufLen); + LOG_INFO("alg: %{public}d wholelen: %{public}d", alg, rawBufLen); while (rawBufLen > 0) { mbedtls_md_init(mdCtx); int32_t readLen = (rawBufLen > HASH_BLOB_LEN) ? HASH_BLOB_LEN : rawBufLen; @@ -67,7 +67,7 @@ static int32_t ComputeBlockHash(const char *block, int32_t blockLen, int32_t alg } ret = mbedtls_md_update(mdCtx, chunkContentPrefix, HAP_DIGEST_PRIFIX_LEN); P_ERR_GOTO_WTTH_LOG(ret); - LOG_INFO("content: %d, %d", rawBufLen, pos); + LOG_INFO("content: %{public}d, %{public}d", rawBufLen, pos); ret = mbedtls_md_update(mdCtx, (unsigned char *)block + pos, readLen); P_ERR_GOTO_WTTH_LOG(ret); rawBufLen -= readLen; @@ -100,10 +100,10 @@ static int32_t GetChunkSumCount(int32_t fileSize, int32_t coreDirectorySize, int int32_t count = ((fileSize - 1 + chunkSize) / chunkSize) + ((coreDirectorySize - 1 + chunkSize) / chunkSize) + ((eocdSize - 1 + chunkSize) / chunkSize); if (rootHashLen < 0 || (((INT_MAX - HAP_DIGEST_PRIFIX_LEN) / count) < rootHashLen)) { - LOG_ERROR("overflow count: %d, chunkDigestLen: %d", count, rootHashLen); + LOG_ERROR("overflow count: %{public}d, chunkDigestLen: %{public}d", count, rootHashLen); return 0; } - LOG_INFO("get sum count %d", count); + LOG_INFO("get sum count %{public}d", count); return count; } @@ -114,7 +114,7 @@ static int32_t ComputeDigestsWithOptionalBlock(const int32_t digestAlgorithm, in char *rawBuf = NULL; unsigned char* outbuf = NULL; int32_t rootHashLen = GetHashUnitLen(digestAlgorithm); - LOG_INFO("rootHashLen %d", rootHashLen); + LOG_INFO("rootHashLen %{public}d", rootHashLen); if (rootHashLen <= 0 || rootHashLen > MAX_HASH_SIZE) { return rst; } @@ -131,14 +131,14 @@ static int32_t ComputeDigestsWithOptionalBlock(const int32_t digestAlgorithm, in ret = mbedtls_md_starts(mdCtx); P_ERR_GOTO_WTTH_LOG(ret); int32_t readLen = chunkDigest->len; - LOG_INFO("readLen %d", readLen); + LOG_INFO("readLen %{public}d", readLen); ret = mbedtls_md_update(mdCtx, chunkDigest->buffer, readLen); P_ERR_GOTO_WTTH_LOG(ret); rawBuf = GetSignBlockByType(signInfo, fp, PROFILE_BLOCK_WITHSIGN_TYPE, &rawLen, &blockHead); P_NULL_GOTO_WTTH_LOG(rawBuf); readLen = rawLen; - LOG_INFO("signBuf %0x %d", rawBuf[0], readLen); + LOG_INFO("signBuf %0x %{public}d", rawBuf[0], readLen); ret = mbedtls_md_update(mdCtx, (unsigned char *)rawBuf, readLen); P_ERR_GOTO_WTTH_LOG(ret); outbuf = (unsigned char *)APPV_MALLOC(rootHashLen); @@ -193,7 +193,7 @@ static int32_t UpdateSmallBlock(int32_t readLen, const int32_t fp, mbedtls_md_co P_NULL_RETURN_WTTH_LOG(onceBuf); int32_t len = read(fp, onceBuf, sizeof(char) * onceRead); if (len != onceRead) { - LOG_ERROR("fread err: %d, %d", len, onceRead); + LOG_ERROR("fread err: %{public}d, %{public}d", len, onceRead); APPV_FREE(onceBuf); return V_ERR; } @@ -223,7 +223,7 @@ static int32_t ComputerFileHash(const SignatureInfo *signInfo, int32_t digestAlg } int32_t ret = HapUpdateDigistHead(digestAlgorithm, mdCtx, mdInfo, readLen, &hlen); P_ERR_GOTO_WTTH_LOG(ret); - LOG_INFO("content: %d, %d", rawBufLen, pos); + LOG_INFO("content: %{public}d, %{public}d", rawBufLen, pos); ret = UpdateSmallBlock(readLen, fp, mdCtx); P_ERR_GOTO_WTTH_LOG(ret); rawBufLen -= readLen; @@ -258,7 +258,7 @@ static int32_t ComputerCoreDirHash(const SignatureInfo *signInfo, int32_t digest lseek(fp, signInfo->hapCoreDirOffset, SEEK_SET); int32_t len = read(fp, dirBuf, sizeof(char) * centralDirSize); if (len != centralDirSize) { - LOG_ERROR("fread err: %d, %d", len, centralDirSize); + LOG_ERROR("fread err: %{public}d, %{public}d", len, centralDirSize); APPV_FREE(dirBuf); return V_ERR; } @@ -280,7 +280,7 @@ static int32_t ComputerEocdHash(const SignatureInfo *signInfo, int32_t digestAlg lseek(fp, signInfo->hapEocdOffset, SEEK_SET); int32_t len = read(fp, eocdBuf, signInfo->hapEocdSize); if (len != signInfo->hapEocdSize) { - LOG_ERROR("fread err: %d, %d", len, signInfo->hapEocdSize); + LOG_ERROR("fread err: %{public}d, %{public}d", len, signInfo->hapEocdSize); APPV_FREE(eocdBuf); return V_ERR; } @@ -315,7 +315,7 @@ bool VerifyIntegrityChunk(int32_t digestAlgorithm, const int32_t fp, if (!CreateHapBuffer(&chunkDigest, sumOfChunksLen)) { return false; } - LOG_INFO("alg: %d", digestAlgorithm); + LOG_INFO("alg: %{public}d", digestAlgorithm); HapPutByte(&chunkDigest, 0, HAP_FIRST_LEVEL_CHUNK_PREFIX); HapSetInt32(&chunkDigest, 1, sumCount); int32_t offset = HAP_DIGEST_PRIFIX_LEN; diff --git a/interfaces/innerkits/appverify_lite/src/mbedtls_pkcs7.c b/interfaces/innerkits/appverify_lite/src/mbedtls_pkcs7.c index ecf38b62d0fc826fc069d98c4ce1e60c23fde5ba..5cfedc4452e9d19281365613f3ed22273c6c70f2 100644 --- a/interfaces/innerkits/appverify_lite/src/mbedtls_pkcs7.c +++ b/interfaces/innerkits/appverify_lite/src/mbedtls_pkcs7.c @@ -48,7 +48,7 @@ do { \ if ((rc) != PKCS7_SUCC) \ { \ - LOG_ERROR("%s:%u, error occurred, ret:%d", __FUNCTION__, __LINE__, (rc)); \ + LOG_ERROR("%s:%u, error occurred, ret:%{public}d", __FUNCTION__, __LINE__, (rc)); \ return rc; \ } \ } while (0) @@ -435,7 +435,7 @@ static int32_t ParseSignedDataVersion(unsigned char **p, const unsigned char *en } if (*ver != PKCS7_SIGNED_DATA_VERSION) { - LOG_ERROR("Invalid version : %d\n", *ver); + LOG_ERROR("Invalid version : %{public}d\n", *ver); return PKCS7_INVALID_VERSION; } LOG_INFO("Parse signed data version success\n"); @@ -626,7 +626,7 @@ static int32_t ParseSignedData(unsigned char *buf, size_t bufLen, SignedData *si /* parse signerInfos */ rc = ParseSignedDataSignerInfos(&p, end, &signedData->signers); - LOG_INFO("ParseSignedData %d", rc); + LOG_INFO("ParseSignedData %{public}d", rc); return rc; } @@ -943,7 +943,7 @@ static int32_t LoadDebugModeRootCert(void) int32_t rc = mbedtls_x509_crt_parse(&g_debugModeRootCert, DEBUG_MODE_ROOT_CERT_IN_PEM, sizeof(DEBUG_MODE_ROOT_CERT_IN_PEM)); if (rc) { - LOG_ERROR("load debug mode root ca failed %d", rc); + LOG_ERROR("load debug mode root ca failed %{public}d", rc); return rc; } else { LOG_INFO("load debug mode root ca success"); @@ -961,7 +961,7 @@ static int32_t LoadSelfSignedCert(void) mbedtls_x509_crt_init(&g_ohosRootCert); int32_t rc = mbedtls_x509_crt_parse(&g_ohosRootCert, OHOS_ROOT_CERT_IN_PEM, sizeof(OHOS_ROOT_CERT_IN_PEM)); if (rc) { - LOG_ERROR("load self signed ca failed %d", rc); + LOG_ERROR("load self signed ca failed %{public}d", rc); return rc; } else { LOG_INFO("load self signed root ca success"); @@ -1051,10 +1051,10 @@ int32_t PKCS7_VerifyCertsChain(const Pkcs7 *pkcs7) } int32_t rc; cnt++; - LOG_INFO("signer : %d", cnt); + LOG_INFO("signer : %{public}d", cnt); if (g_debugModeEnabled) { rc = VerifyClicert(clicert, &g_debugModeRootCert, pkcs7); - LOG_DEBUG("Verify inner: %d", rc); + LOG_DEBUG("Verify inner: %{public}d", rc); if (rc == PKCS7_SUCC) { signer = signer->next; continue; @@ -1064,7 +1064,7 @@ int32_t PKCS7_VerifyCertsChain(const Pkcs7 *pkcs7) } } rc = VerifyClicert(clicert, signer->rootCert, pkcs7); - LOG_DEBUG("Verify : %d", rc); + LOG_DEBUG("Verify : %{public}d", rc); if (rc == PKCS7_SUCC) { signer = signer->next; continue; @@ -1074,7 +1074,7 @@ int32_t PKCS7_VerifyCertsChain(const Pkcs7 *pkcs7) } #ifndef OHOS_SIGN_HAPS_BY_SERVER rc = VerifyClicert(clicert, &g_ohosRootCert, pkcs7); - LOG_DEBUG("Verify self : %d", rc); + LOG_DEBUG("Verify self : %{public}d", rc); if (rc == PKCS7_SUCC) { signer = signer->next; continue;