mirror of
https://gitee.com/openharmony/security_deviceauth
synced 2024-11-30 08:00:26 +00:00
fix review bugs
Signed-off-by: fuzikun <fuzikun@huawei.com>
This commit is contained in:
parent
d112fd1cff
commit
449be312cd
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "clib_types.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
|
||||
void *ClibMalloc(uint32_t size, char val)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ HcParcel CreateParcel(uint32_t size, uint32_t allocUnit)
|
||||
parcel.allocUnit = PARCEL_DEFAULT_INCREASE_STEP;
|
||||
}
|
||||
if (size > 0) {
|
||||
parcel.data = (char*)ClibMalloc(size, 0);
|
||||
parcel.data = (char *)ClibMalloc(size, 0);
|
||||
if (parcel.data != NULL) {
|
||||
parcel.length = size;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "json_utils.h"
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "clib_error.h"
|
||||
#include "clib_types.h"
|
||||
#include "string_util.h"
|
||||
@ -203,12 +203,7 @@ int32_t GetByteFromJson(const CJson *jsonObj, const char *key, uint8_t *byte, ui
|
||||
if (len < strlen(valueStr) / BYTE_TO_HEX_OPER_LENGTH) {
|
||||
return CLIB_ERR_INVALID_LEN;
|
||||
}
|
||||
int32_t ret = HexStringToByte(valueStr, byte, len);
|
||||
if (ret != CLIB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return HexStringToByte(valueStr, byte, len);
|
||||
}
|
||||
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int32_t *value)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "clib_error.h"
|
||||
#include "clib_types.h"
|
||||
|
||||
@ -228,8 +228,7 @@ int32_t ByteToBase64String(const uint8_t *byte, uint32_t byteLen, char *base64St
|
||||
if (byteLen % 3 == 1) {
|
||||
base64Str[i - 2] = '=';
|
||||
base64Str[i - 1] = '=';
|
||||
}
|
||||
if (byteLen % 3 == 2) {
|
||||
} else if (byteLen % 3 == 2) {
|
||||
base64Str[i - 1] = '=';
|
||||
}
|
||||
base64Str[len] = '\0';
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "mbedtls_hash_to_point.h"
|
||||
#include <stdio.h>
|
||||
#include <mbedtls/bignum.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "alg_defs.h"
|
||||
#include "hal_error.h"
|
||||
#include "hc_log.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "hc_log.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
|
||||
#define LOG_PRINT_MAX_LEN 256
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "securec.h"
|
||||
#include "hc_log.h"
|
||||
#include "hc_types.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -123,8 +123,8 @@ int HcFileRead(FileHandle file, void *dst, int dstSize)
|
||||
int total = 0;
|
||||
while (total < dstSize) {
|
||||
int readCount = fread(dstBuffer + total, 1, dstSize - total, fp);
|
||||
if ((readCount < 0) || (readCount > (dstSize - total))) {
|
||||
return -1;
|
||||
if (ferror(fp) != 0) {
|
||||
LOGE("read file error!");
|
||||
}
|
||||
if (readCount == 0) {
|
||||
return total;
|
||||
@ -146,8 +146,8 @@ int HcFileWrite(FileHandle file, const void *src, int srcSize)
|
||||
int total = 0;
|
||||
while (total < srcSize) {
|
||||
int writeCount = fwrite(srcBuffer + total, 1, srcSize - total, fp);
|
||||
if (writeCount < 0 || writeCount > (srcSize - total)) {
|
||||
return -1;
|
||||
if (ferror(fp) != 0) {
|
||||
LOGE("write file error!");
|
||||
}
|
||||
total += writeCount;
|
||||
}
|
||||
@ -196,6 +196,9 @@ void HcFileGetSubFileName(const char *path, StringVector *nameVec)
|
||||
DeleteString(&subFileName);
|
||||
}
|
||||
}
|
||||
if (closedir(dir) < 0) {
|
||||
LOGE("Failed to close file");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -17,11 +17,11 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <securec.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "hal_error.h"
|
||||
#include "hc_log.h"
|
||||
#include "securec.h"
|
||||
#include "utils_file.h"
|
||||
|
||||
#define MAX_FOLDER_NAME_SIZE 128
|
||||
@ -136,8 +136,11 @@ void HcFileGetSubFileName(const char *path, StringVector *nameVec)
|
||||
continue;
|
||||
}
|
||||
if (nameVec->pushBackT(nameVec, subFileName) == NULL) {
|
||||
LOGE("Failed to push path to pathVec!");
|
||||
LOGE("Failed to push name!");
|
||||
DeleteString(&subFileName);
|
||||
}
|
||||
}
|
||||
if (closedir(dir) < 0) {
|
||||
LOGE("Failed to close file");
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "add_auth_info.h"
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
@ -192,7 +192,7 @@ int32_t import_signed_auth_info_hilink(const struct hichain *hichain, const stru
|
||||
uint32_t len = (data->length / BYTE_TO_HEX_OPER_LENGTH) + 1;
|
||||
uint8_t *receive_data = (uint8_t *)MALLOC(len);
|
||||
if (receive_data == NULL) {
|
||||
LOGE("malloc inport signed auth info receive data failed");
|
||||
LOGE("malloc import signed auth info receive data failed");
|
||||
return HC_MALLOC_FAILED;
|
||||
}
|
||||
(void)memset_s(receive_data, len, 0, len);
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "add_auth_info_client.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "auth_info.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "huks_adapter.h"
|
||||
@ -78,7 +78,7 @@ int32_t encrypt_payload(const struct var_buffer *key, const struct uint8_buff *p
|
||||
struct aes_aad aes_aad;
|
||||
(void)memset_s(&aes_aad, sizeof(aes_aad), 0, sizeof(aes_aad));
|
||||
if (strcpy_s((char *)aes_aad.aad, sizeof(aes_aad.aad), aad) != EOK) {
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memery error, no return */
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memory error, no return */
|
||||
}
|
||||
aes_aad.length = strlen(aad);
|
||||
int32_t ret = aes_gcm_encrypt((struct var_buffer *)key, plain, &aes_aad, payload);
|
||||
@ -104,7 +104,7 @@ int32_t decrypt_payload(const struct var_buffer *key, const struct uint8_buff *p
|
||||
struct aes_aad aes_aad;
|
||||
(void)memset_s(&aes_aad, sizeof(aes_aad), 0, sizeof(aes_aad));
|
||||
if (strcpy_s((char *)aes_aad.aad, sizeof(aes_aad.aad), aad) != EOK) {
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memery error, no return */
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memory error, no return */
|
||||
}
|
||||
aes_aad.length = strlen(aad);
|
||||
int32_t ret = aes_gcm_decrypt((struct var_buffer *)key, payload, &aes_aad, plain);
|
||||
|
@ -16,7 +16,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include "exchange_auth_info.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_CLIENT_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_CLIENT_))
|
||||
#include "exchange_auth_info_client.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "remove_auth_info_client.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "commonutil.h"
|
||||
#include "distribution.h"
|
||||
#include "log.h"
|
||||
@ -242,7 +242,7 @@ int32_t init_center(const struct hc_package_name *package_name, const struct hc_
|
||||
LOGE("Generate derived dek failed");
|
||||
return ret;
|
||||
}
|
||||
if (memcpy_s(dek, sizeof(struct hc_key_alias), &dek_alias, sizeof(struct hc_key_alias)) != HC_OK) {
|
||||
if (memcpy_s(dek, sizeof(struct hc_key_alias), &dek_alias, sizeof(struct hc_key_alias)) != EOK) {
|
||||
return HC_INNER_ERROR;
|
||||
}
|
||||
|
||||
@ -1175,7 +1175,7 @@ static int32_t delete_public_key(hc_handle handle, struct service_id service_id,
|
||||
(void)memset_s(auth_id_list, length, 0, length);
|
||||
|
||||
uint32_t peers_num = list_trust_peers(handle, user_type, NULL, &auth_id_list);
|
||||
LOGI("peers_num %d", peers_num);
|
||||
LOGI("peers_num %u", peers_num);
|
||||
for (uint32_t loop = 0; loop < peers_num; loop++) {
|
||||
struct hc_key_alias key_alias = generate_key_alias(&service_id, &auth_id_list[loop], user_type);
|
||||
if (key_alias.length == 0) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "commonutil.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "base.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
@ -22,7 +22,8 @@
|
||||
|
||||
char hex_to_char(uint8_t hex)
|
||||
{
|
||||
return (hex > 9) ? hex + 0x37 : hex + 0x30; /* Convert to the corresponding character */
|
||||
/* Convert to the corresponding character, hex + 0x37 -> A-F, hex + 0x30 -> 0-9 */
|
||||
return (hex > 9) ? hex + 0x37 : hex + 0x30;
|
||||
}
|
||||
|
||||
void byte_to_hex_string(const uint8_t *hex, int32_t hex_len, uint8_t *buf, int32_t buf_len)
|
||||
@ -117,22 +118,6 @@ int32_t string_convert(json_pobject obj, const char *field, uint8_t *str, uint32
|
||||
return HC_OK;
|
||||
}
|
||||
|
||||
void hex_string_convert(uint32_t length, const uint8_t *hex, const char *field, json_pobject parent)
|
||||
{
|
||||
int32_t org_cha_len = length;
|
||||
int32_t tmp_cha_data_hex_len = org_cha_len * BYTE_TO_HEX_OPER_LENGTH + 1;
|
||||
uint8_t *tmp_cha_data_hex = (uint8_t *)MALLOC(tmp_cha_data_hex_len);
|
||||
|
||||
if (tmp_cha_data_hex == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)memset_s(tmp_cha_data_hex, tmp_cha_data_hex_len, 0, tmp_cha_data_hex_len);
|
||||
byte_to_hex_string(hex, org_cha_len, tmp_cha_data_hex, org_cha_len * BYTE_TO_HEX_OPER_LENGTH);
|
||||
add_string_to_object(parent, field, (char *)tmp_cha_data_hex);
|
||||
FREE(tmp_cha_data_hex);
|
||||
tmp_cha_data_hex = NULL;
|
||||
}
|
||||
|
||||
int32_t memory_copy_error(const char *fun, unsigned int line)
|
||||
{
|
||||
(void)fun;
|
||||
|
@ -28,7 +28,6 @@ void print_bytes(uint8_t *buf, int32_t buf_len);
|
||||
|
||||
int32_t byte_convert(json_pobject obj, const char *field, uint8_t *hex, uint32_t *length, uint32_t max_len);
|
||||
int32_t string_convert(json_pobject obj, const char *field, uint8_t *str, uint32_t *length, uint32_t max_len);
|
||||
void hex_string_convert(uint32_t length, const uint8_t *hex, const char *field, json_pobject parent);
|
||||
|
||||
int32_t memory_copy_error(const char *fun, unsigned int line);
|
||||
|
||||
|
@ -27,10 +27,10 @@ json_handle parse_json(const char *data)
|
||||
return (void *)root;
|
||||
}
|
||||
|
||||
void free_json(json_handle hanlde)
|
||||
void free_json(json_handle handle)
|
||||
{
|
||||
if (hanlde != NULL) {
|
||||
cJSON_Delete((cJSON *)hanlde);
|
||||
if (handle != NULL) {
|
||||
cJSON_Delete((cJSON *)handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ typedef void *json_handle;
|
||||
typedef void *json_pobject;
|
||||
|
||||
json_handle parse_json(const char *data);
|
||||
void free_json(json_handle hanlde);
|
||||
void free_json(json_handle handle);
|
||||
|
||||
json_pobject get_json_obj(json_pobject parent, const char *field);
|
||||
int32_t get_json_int(json_pobject obj, const char *field);
|
||||
|
@ -62,7 +62,7 @@ int32_t send_start_response(void *handle, void *receive_data, void *send_data)
|
||||
}
|
||||
set_state(base, START_RESPONSE);
|
||||
set_last_time_sec(base);
|
||||
DBG_OUT("Object %u receive start request data send start response data succcess", base->sn);
|
||||
DBG_OUT("Object %u receive start request data send start response data success", base->sn);
|
||||
return HC_OK;
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ int32_t send_end_response(void *handle, void *receive_data, void *send_data)
|
||||
}
|
||||
set_state(base, PROTOCOL_FINISH);
|
||||
set_last_time_sec(base);
|
||||
DBG_OUT("Object %u receive end request data send end response data succcess", base->sn);
|
||||
DBG_OUT("Object %u receive end request data send end response data success", base->sn);
|
||||
return HC_OK;
|
||||
}
|
||||
#endif /* DESC */
|
||||
|
@ -20,7 +20,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_CLIENT_))
|
||||
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "sec_clone_server.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "commonutil.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_CLIENT_))
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "commonutil.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "commonutil.h"
|
||||
#include "distribution.h"
|
||||
#include "mem_stat.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#ifndef _HC_DEBUG_
|
||||
|
||||
#include "log.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "base.h"
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "build_object.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "auth_info.h"
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "distribution.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "pake_client.h"
|
||||
#include "pake_server.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
@ -90,8 +90,8 @@ void free_auth_start_request(void *obj)
|
||||
}
|
||||
}
|
||||
|
||||
static char *make_requst_json_str(struct sts_start_request_data *auth_start_request,
|
||||
struct sts_start_request_data_hex tmp_hex)
|
||||
static char *make_request_json_str(struct sts_start_request_data *auth_start_request,
|
||||
struct sts_start_request_data_hex tmp_hex)
|
||||
{
|
||||
char *tmp_str = (char *)MALLOC(RET_STR_LENGTH);
|
||||
if (tmp_str == NULL) {
|
||||
@ -156,7 +156,7 @@ char *make_auth_start_request(void *data)
|
||||
FREE(tmp_hex.tmp_cha_data_hex);
|
||||
return NULL;
|
||||
}
|
||||
char *ret_str = make_requst_json_str(auth_start_request, tmp_hex);
|
||||
char *ret_str = make_request_json_str(auth_start_request, tmp_hex);
|
||||
FREE(tmp_hex.tmp_epk_data_hex);
|
||||
FREE(tmp_hex.tmp_cha_data_hex);
|
||||
FREE(tmp_hex.tmp_type_data_hex);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "key_agreement_version.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <log.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
#include "commonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "parsedata.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
#include "log.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#if (defined(_SUPPORT_SEC_CLONE_) || defined(_SUPPORT_SEC_CLONE_SERVER_))
|
||||
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "jsonutil.h"
|
||||
#include "commonutil.h"
|
||||
#include "exchange_auth_info.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "deviceauth_test.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "hichain.h"
|
||||
|
||||
#define LOG(format, ...) (printf(format"\n", ##__VA_ARGS__))
|
||||
@ -54,7 +54,7 @@ static void Transmit(const struct session_identity *identity, const void *data,
|
||||
LOG("--------Transmit--------");
|
||||
LOG("identity session_id[%d] package_name[%s]", identity->session_id, identity->package_name.name);
|
||||
LOG("data[%s]", (char *)data);
|
||||
LOG("length[%d]", length);
|
||||
LOG("length[%u]", length);
|
||||
LOG("--------Transmit--------");
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ extern "C" {
|
||||
|
||||
typedef struct {
|
||||
SvcIdentity stubIdentity;
|
||||
bool registed;
|
||||
bool registered;
|
||||
} StubDevAuthCb;
|
||||
|
||||
int32_t CbStubOnRemoteRequest(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void *arg);
|
||||
|
@ -1392,8 +1392,8 @@ void SetCbCtxToDataCtx(uintptr_t callCtx, int32_t cbIdx)
|
||||
ProxyDevAuthData *dataCache = NULL;
|
||||
const SvcIdentity *stubInfo = &g_sdkCbStub.stubIdentity;
|
||||
(void)cbIdx;
|
||||
if (!g_sdkCbStub.registed) {
|
||||
LOGW("SDK callback stub un-registed");
|
||||
if (!g_sdkCbStub.registered) {
|
||||
LOGW("SDK callback stub un-registered");
|
||||
return;
|
||||
}
|
||||
ShowIpcSvcInfo(stubInfo);
|
||||
@ -1661,7 +1661,7 @@ int32_t InitProxyAdapt(void)
|
||||
LOGI("get proxy instance success");
|
||||
}
|
||||
|
||||
if (!g_sdkCbStub.registed) {
|
||||
if (!g_sdkCbStub.registered) {
|
||||
ret = RegisterIpcCallback(CbStubOnRemoteRequest, 0, IPC_WAIT_FOREVER, &(g_sdkCbStub.stubIdentity), NULL);
|
||||
if (ret != 0) {
|
||||
LOGE("register ipc cb failed");
|
||||
@ -1669,7 +1669,7 @@ int32_t InitProxyAdapt(void)
|
||||
}
|
||||
ShowIpcSvcInfo(&(g_sdkCbStub.stubIdentity));
|
||||
LOGI("register ipc cb success");
|
||||
g_sdkCbStub.registed = true;
|
||||
g_sdkCbStub.registered = true;
|
||||
}
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
@ -1680,7 +1680,7 @@ void UnInitProxyAdapt(void)
|
||||
if (UnregisterIpcCallback(g_sdkCbStub.stubIdentity)) {
|
||||
LOGW("un-register ipc cb failed");
|
||||
}
|
||||
g_sdkCbStub.registed = false;
|
||||
g_sdkCbStub.registered = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static int32_t BinderLiteProcess(SvcIdentity **svc, int32_t procType)
|
||||
(void)BinderRelease((*svc)->ipcContext, (*svc)->handle);
|
||||
break;
|
||||
default:
|
||||
LOGW("internal error: unknow processing type");
|
||||
LOGW("internal error: unknown processing type");
|
||||
}
|
||||
#endif
|
||||
return (ret == 0) ? HC_SUCCESS : HC_ERROR;
|
||||
|
@ -140,7 +140,7 @@ enum {
|
||||
BAD_PAYLOAD = 0xF000000B,
|
||||
ALGORITHM_UNSUPPORTED = 0xF000000C,
|
||||
PROOF_MISMATCH = 0xF000000D,
|
||||
UNKOWN = 0xF0000000,
|
||||
UNKNOWN = 0xF0000000,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -61,7 +61,7 @@ bool IsDasMsgNeedIgnore(const CJson *in)
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGI("The message needs to ignore, message: %u.", message);
|
||||
LOGI("The message needs to ignore, message: %d.", message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -402,12 +402,12 @@ int32_t GetAndCheckAuthIdPeer(const CJson *in, const Uint8Buff *authIdSelf, cons
|
||||
return HC_ERR_CONVERT_FAILED;
|
||||
}
|
||||
if ((authIdSelf->length == authIdPeer->length) &&
|
||||
memcmp(authIdSelf->val, authIdPeer->val, authIdSelf->length) == 0) {
|
||||
memcmp(authIdSelf->val, authIdPeer->val, authIdSelf->length) == EOK) {
|
||||
LOGE("Peer id can not be equal to self id.");
|
||||
HcFree(authIdPeerTmp);
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
if (memcmp(authIdPeer->val, authIdPeerTmp, authIdPeer->length) != 0) {
|
||||
if (memcmp(authIdPeer->val, authIdPeerTmp, authIdPeer->length) != EOK) {
|
||||
LOGE("Peer authId does not match.");
|
||||
HcFree(authIdPeerTmp);
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
|
@ -127,10 +127,7 @@ static bool EndWithZero(HcParcel *parcel)
|
||||
if (p == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (*p == '\0') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (*p == '\0');
|
||||
}
|
||||
|
||||
static bool LoadStringVectorFromParcel(StringVector *vec, HcParcel *parcel)
|
||||
@ -201,7 +198,7 @@ static bool GetOsAccountInfoPath(int32_t osAccountId, char *infoPath, uint32_t p
|
||||
{
|
||||
const char *beginPath = GetStorageDirPath();
|
||||
if (beginPath == NULL) {
|
||||
LOGE("[DB]: Failed to get the stroage path dir!");
|
||||
LOGE("[DB]: Failed to get the storage path dir!");
|
||||
return false;
|
||||
}
|
||||
int32_t ret;
|
||||
@ -424,13 +421,13 @@ static bool ReadParcelFromFile(int32_t osAccountId, HcParcel *parcel)
|
||||
}
|
||||
int fileSize = HcFileSize(file);
|
||||
if (fileSize <= 0) {
|
||||
LOGE("[DB]: The databse file size is invalid!");
|
||||
LOGE("[DB]: The database file size is invalid!");
|
||||
HcFileClose(file);
|
||||
return false;
|
||||
}
|
||||
char *fileData = (char *)HcMalloc(fileSize, 0);
|
||||
if (fileData == NULL) {
|
||||
LOGE("[DB]: Failed to allocate fileData memroy!");
|
||||
LOGE("[DB]: Failed to allocate fileData memory!");
|
||||
HcFileClose(file);
|
||||
return false;
|
||||
}
|
||||
@ -697,16 +694,25 @@ static TrustedDeviceEntry **QueryDeviceEntryPtrIfMatch(const DeviceEntryVec *vec
|
||||
|
||||
static void PostGroupCreatedMsg(const TrustedGroupEntry *groupEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
GetBroadcaster()->postOnGroupCreated(groupEntry);
|
||||
}
|
||||
|
||||
static void PostGroupDeletedMsg(const TrustedGroupEntry *groupEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
GetBroadcaster()->postOnGroupDeleted(groupEntry);
|
||||
}
|
||||
|
||||
static void PostDeviceBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
QueryGroupParams groupParams = InitQueryGroupParams();
|
||||
groupParams.groupId = StringGet(&deviceEntry->groupId);
|
||||
TrustedGroupEntry **groupEntryPtr = QueryGroupEntryPtrIfMatch(&info->groups, &groupParams);
|
||||
@ -717,11 +723,21 @@ static void PostDeviceBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEn
|
||||
|
||||
static void PostDeviceUnBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
const char *groupId = StringGet(&deviceEntry->groupId);
|
||||
const char *udid = StringGet(&deviceEntry->udid);
|
||||
QueryGroupParams groupParams = InitQueryGroupParams();
|
||||
groupParams.groupId = StringGet(&deviceEntry->groupId);
|
||||
groupParams.groupId = groupId;
|
||||
TrustedGroupEntry **groupEntryPtr = QueryGroupEntryPtrIfMatch(&info->groups, &groupParams);
|
||||
if (groupEntryPtr != NULL) {
|
||||
GetBroadcaster()->postOnDeviceUnBound(StringGet(&deviceEntry->udid), *groupEntryPtr);
|
||||
GetBroadcaster()->postOnDeviceUnBound(udid, *groupEntryPtr);
|
||||
}
|
||||
QueryDeviceParams deviceParams = InitQueryDeviceParams();
|
||||
deviceParams.udid = udid;
|
||||
if (QueryDeviceEntryPtrIfMatch(&info->devices, &deviceParams) == NULL) {
|
||||
GetBroadcaster()->postOnDeviceNotTrusted(udid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,7 +1037,7 @@ int32_t QueryGroups(int32_t osAccountId, const QueryGroupParams *params, GroupEn
|
||||
continue;
|
||||
}
|
||||
if (vec->pushBackT(vec, newEntry) == NULL) {
|
||||
LOGE("[DB]: Faild to push entry to vec!");
|
||||
LOGE("[DB]: Failed to push entry to vec!");
|
||||
DestroyGroupEntry(newEntry);
|
||||
}
|
||||
}
|
||||
@ -1053,7 +1069,7 @@ int32_t QueryDevices(int32_t osAccountId, const QueryDeviceParams *params, Devic
|
||||
continue;
|
||||
}
|
||||
if (vec->pushBackT(vec, newEntry) == NULL) {
|
||||
LOGE("[DB]: Faild to push entry to vec!");
|
||||
LOGE("[DB]: Failed to push entry to vec!");
|
||||
DestroyDeviceEntry(newEntry);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int32_t GetInfoHash(const uint8_t *info, uint32_t infoLen, char *str, uint32_t s
|
||||
}
|
||||
int32_t res;
|
||||
do {
|
||||
if (memcpy_s(message.val, message.length, info, infoLen) != HC_SUCCESS) {
|
||||
if (memcpy_s(message.val, message.length, info, infoLen) != EOK) {
|
||||
LOGE("Failed to copy data!");
|
||||
res = HC_ERR_ALLOC_MEMORY;
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ static int32_t AddChannelEntry(int64_t requestId, int64_t channelId)
|
||||
{
|
||||
int64_t tmpReqId = DEFAULT_REQUEST_ID;
|
||||
if (GetReqIdByChannelId(channelId, &tmpReqId) == HC_SUCCESS) {
|
||||
LOGE("A request to use the channel alreay exists!");
|
||||
LOGE("A request to use the channel already exists!");
|
||||
return HC_ERR_REQUEST_EXIST;
|
||||
}
|
||||
ChannelEntry entry = {
|
||||
@ -149,7 +149,7 @@ static char *GenRecvData(int64_t channelId, const void *data, uint32_t dataLen,
|
||||
|
||||
static bool IsServer(int sessionId)
|
||||
{
|
||||
return (GetSessionSide(sessionId) == 0) ? true : false;
|
||||
return GetSessionSide(sessionId) == 0;
|
||||
}
|
||||
|
||||
static int OnChannelOpenedCb(int sessionId, int result)
|
||||
|
@ -998,7 +998,7 @@ int32_t ProcessKeyPair(int action, const CJson *jsonParams, const char *groupId)
|
||||
LOGE("Failed to allocate authIdBuff memory!");
|
||||
return HC_ERR_ALLOC_MEMORY;
|
||||
}
|
||||
if (memcpy_s(authIdBuff.val, authIdBuff.length, authId, authIdBuff.length) != HC_SUCCESS) {
|
||||
if (memcpy_s(authIdBuff.val, authIdBuff.length, authId, authIdBuff.length) != EOK) {
|
||||
LOGE("Failed to copy authId!");
|
||||
HcFree(authIdBuff.val);
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
|
Loading…
Reference in New Issue
Block a user