diff --git a/frameworks/certificate/cert_chain_validator.c b/frameworks/certificate/cert_chain_validator.c index 60c63ce640d8af813fab12dac913889a9654a3e6..09fa4d2b6d6fb3f3dc86008628b08042d0143a87 100644 --- a/frameworks/certificate/cert_chain_validator.c +++ b/frameworks/certificate/cert_chain_validator.c @@ -53,7 +53,7 @@ static const HcfCertChainValidatorAbility CERT_PATH_VALIDATOR_ABILITY_SET[] = { static const HcfCertChainValidatorFuncSet *FindAbility(const char *algorithm) { - for (uint32_t i = 0; i < sizeof(CERT_PATH_VALIDATOR_ABILITY_SET); i++) { + for (uint32_t i = 0; i < sizeof(CERT_PATH_VALIDATOR_ABILITY_SET) / sizeof(HcfCertChainValidatorAbility); i++) { if (strcmp(CERT_PATH_VALIDATOR_ABILITY_SET[i].algorithm, algorithm) == 0) { return &(CERT_PATH_VALIDATOR_ABILITY_SET[i].funcSet); } diff --git a/frameworks/certificate/x509_certificate.c b/frameworks/certificate/x509_certificate.c index 4095f99dbfc3fe38731a99c9292e4e9464e792e4..abadcf4d7b5ea19425c93ca72e8c158d4cf391ec 100644 --- a/frameworks/certificate/x509_certificate.c +++ b/frameworks/certificate/x509_certificate.c @@ -50,7 +50,7 @@ static const HcfX509CertificateFuncSet *FindAbility(const char *certType) LOGE("CertType is null!"); return NULL; } - for (uint32_t i = 0; i < sizeof(X509_CERTIFICATE_ABILITY_SET); i++) { + for (uint32_t i = 0; i < sizeof(X509_CERTIFICATE_ABILITY_SET) / sizeof(HcfCCertFactoryAbility); i++) { if (strcmp(X509_CERTIFICATE_ABILITY_SET[i].certType, certType) == 0) { return &(X509_CERTIFICATE_ABILITY_SET[i].funcSet); } diff --git a/frameworks/certificate/x509_crl.c b/frameworks/certificate/x509_crl.c index 4109df0ac07789c18dfd9626aa70ac68e4b5a466..4ed3818824c5d3b577dc0e9eba2cc0cb4e6b6762 100644 --- a/frameworks/certificate/x509_crl.c +++ b/frameworks/certificate/x509_crl.c @@ -60,7 +60,7 @@ static const HcfX509CrlFuncSet *FindAbility(const char *certType) LOGE("CertType is null!"); return NULL; } - for (uint32_t i = 0; i < sizeof(X509_CRL_ABILITY_SET); i++) { + for (uint32_t i = 0; i < sizeof(X509_CRL_ABILITY_SET) / sizeof(HcfCCertFactoryAbility); i++) { if (strcmp(X509_CRL_ABILITY_SET[i].certType, certType) == 0) { return &(X509_CRL_ABILITY_SET[i].funcSet); } diff --git a/frameworks/key/sym_key_generator.c b/frameworks/key/sym_key_generator.c index fce9ebcb6a99e4ef0c2d45089470fdddf5a627e0..465de2f5a6c9374d6107e394e3fefc2a9627300a 100644 --- a/frameworks/key/sym_key_generator.c +++ b/frameworks/key/sym_key_generator.c @@ -57,7 +57,7 @@ static const SymKeyGenFuncSet *FindAbility(SymKeyAttr *attr) if (attr == NULL) { return NULL; } - for (uint32_t i = 0; i < sizeof(SYMKEY_ABILITY_SET); i++) { + for (uint32_t i = 0; i < sizeof(SYMKEY_ABILITY_SET) / sizeof(SymKeyGenAbility); i++) { if (SYMKEY_ABILITY_SET[i].algo == attr->algo) { return &(SYMKEY_ABILITY_SET[i].funcSet); } diff --git a/test/fuzztest/crypto_operation/hcfciphercreate_fuzzer/hcfciphercreate_fuzzer.cpp b/test/fuzztest/crypto_operation/hcfciphercreate_fuzzer/hcfciphercreate_fuzzer.cpp index e088d166db1cbaff36f62ba32b3aaf1fa5c955a4..addfee153ab533e29a2726192f76a5f7de50b52d 100755 --- a/test/fuzztest/crypto_operation/hcfciphercreate_fuzzer/hcfciphercreate_fuzzer.cpp +++ b/test/fuzztest/crypto_operation/hcfciphercreate_fuzzer/hcfciphercreate_fuzzer.cpp @@ -159,7 +159,7 @@ namespace OHOS { return; } - HcfBlob input = {.data = reinterpret_cast(plan), .len = strlen((char *)plan)}; + HcfBlob input = { .data = plan, .len = strlen(reinterpret_cast(plan)) }; HcfBlob encoutput = {.data = nullptr, .len = 0}; HcfCipher *cipher = nullptr; res = HcfCipherCreate("RSA1024|PKCS1", &cipher); diff --git a/test/unittest/src/crypto_rsa_asy_key_generator_test.cpp b/test/unittest/src/crypto_rsa_asy_key_generator_test.cpp index b9e9afb9aa16e04a18f299ef165a4448fed53722..dfa43e92c60e5a8b075fa9c773fc3e2e7e4b6a3b 100644 --- a/test/unittest/src/crypto_rsa_asy_key_generator_test.cpp +++ b/test/unittest/src/crypto_rsa_asy_key_generator_test.cpp @@ -425,8 +425,8 @@ HWTEST_F(CryptoRsaAsyKeyGeneratorTest, CryptoRsaAsyKeyGeneratorTest511, TestSize HcfKeyPair *keyPair = NULL; res = generator->generateKeyPair(generator, NULL, &keyPair); - HcfBlob pubKeyBlob; - HcfBlob priKeyBlob; + HcfBlob pubKeyBlob = { .data = nullptr, .len = 0 }; + HcfBlob priKeyBlob = { .data = nullptr, .len = 0 }; HcfPubKey *pubKey = keyPair->pubKey; HcfPriKey *priKey = keyPair->priKey;