diff --git a/src/cm_mes/mes_rdma_rpc.c b/src/cm_mes/mes_rdma_rpc.c index 21fed91662cda136fef92cfb247bc09201eea5dc..72c09b2a18718d26cbed9c944c8f63b413a755e4 100644 --- a/src/cm_mes/mes_rdma_rpc.c +++ b/src/cm_mes/mes_rdma_rpc.c @@ -1033,7 +1033,7 @@ void mes_ockrpc_tls_get_private_key(const char** privateKeyPath, char** keypass, // verify ssl key password and KMC module if (mes_verify_ssl_key_pwd(&ssl_cfg, passwd_plain, CM_PASSWD_MAX_LEN) != CM_SUCCESS) { LOG_RUN_ERR("CBB verify ssl key password failed"); - (void)memset_s(passwd_plain, sizeof(passwd_plain), 0, sizeof(passwd_plain)); + (void)memset_s(passwd_plain, max_passwd_size, 0, max_passwd_size); free(passwd_plain); *privateKeyPath = NULL; *keypass = NULL; diff --git a/src/cm_utils/cm_log.c b/src/cm_utils/cm_log.c index f17811b914e98eea34284b26da79c4e450a0afa2..ef1be88f815f0892f13e8bb8d9e4f181c6a5d2c3 100644 --- a/src/cm_utils/cm_log.c +++ b/src/cm_utils/cm_log.c @@ -811,6 +811,8 @@ static status_t compress_file_to_gzip(const char *infilename, const char *outfil } } if (feof(infile) == 0) { + (void)fclose(infile); + (void)gzclose(outfile); return CM_ERROR; } diff --git a/src/ddes_json/ddes_json.c b/src/ddes_json/ddes_json.c index b1cad7a71888c14686f72432e748e54b71c05cde..d31685298e136ff9849be577d7ac921b49c5b89a 100644 --- a/src/ddes_json/ddes_json.c +++ b/src/ddes_json/ddes_json.c @@ -932,16 +932,16 @@ status_t json_get_obj(json_t *json, json_t **obj, text_t *key) status_t json_add_str(json_t *json, const char * const key, const char * const val) { + if ((json == NULL) || (key == NULL)) { + return CM_ERROR; + } + json_val_t *jval; uint32 key_size; uint32 val_size; uint32 key_len = (uint32)strlen(key); uint32 val_len = (uint32)strlen(val); - if ((json == NULL) || (key == NULL)) { - return CM_ERROR; - } - key_size = (uint32)(sizeof(json_val_t) + sizeof(uint16) + key_len + 1); val_size = (uint32)sizeof(jstr_len_t) + val_len + 1; CM_RETURN_IFERR(json->allocator.f_alloc(json->allocator.mem_ctx, key_size + val_size, (void **)&jval));