From 64ee1a3d0761c7816c9b321af2217b91320e95ea Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 27 Dec 2024 16:14:37 +0900 Subject: [PATCH] Fix issues that detected by static analysis tool Change-Id: I55fc1881f13d68d46aeff7e78e731ceb9c5f9e42 Signed-off-by: sungwook79.park --- client/vc_mgr.c | 2 +- client/vc_mgr_tidl.c | 30 +++++++++++++++--------------- client/vc_tidl.c | 12 ++++++------ client/vc_widget_tidl.c | 10 +++++----- common/vc_cmd_db.c | 14 +++++++------- common/vc_json_parser.c | 2 +- server/vcd_client_data.c | 2 +- server/vcd_config.c | 2 +- server/vcd_server.c | 4 ++-- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 0d6659e..cd96015 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -1104,7 +1104,7 @@ int vc_mgr_set_audio_type(const char* audio_id) if (VC_ERROR_NONE != ret) return ret; - if (NULL == audio_id || !strncmp(audio_id, "", strlen(audio_id))) { + if (NULL == audio_id || !strncmp(audio_id, "", strlen(audio_id) + 1)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; } diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index e41e707..3596b40 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -58,7 +58,7 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_METHOD, &method); - if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME))) { + if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME) + 1)) { bundle_get_str(msg, VC_BUNDLE_VOLUME, &val); float volume = 0; @@ -77,7 +77,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_SET_VOLUME */ - else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { + else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE) + 1)) { bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { @@ -87,13 +87,13 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_METHOD_SET_SERVICE_STATE */ - else if (0 == strncmp(VCD_MANAGER_METHOD_SPEECH_DETECTED, method, strlen(VCD_MANAGER_METHOD_SPEECH_DETECTED))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_SPEECH_DETECTED, method, strlen(VCD_MANAGER_METHOD_SPEECH_DETECTED) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get Speech detected"); vc_mgr_core_send_speech_detected(); } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */ - else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get All Result"); bundle_get_str(msg, VC_BUNDLE_RESULT, &val); @@ -103,7 +103,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_ALL_RESULT */ - else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get Pre Result"); char* event = NULL; char* pre_result = NULL; @@ -116,7 +116,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_PRE_RESULT */ - else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get specific engine result"); char* engine_app_id = NULL; char* event = NULL; @@ -138,13 +138,13 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT */ - else if (0 == strncmp(VCD_MANAGER_METHOD_RESULT, method, strlen(VCD_MANAGER_METHOD_RESULT))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_RESULT, method, strlen(VCD_MANAGER_METHOD_RESULT) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get System Result"); vc_mgr_core_send_system_result(); } /* VCD_MANAGER_METHOD_RESULT */ - else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Request Dialog"); char* pid = NULL; char* disp_text = NULL; @@ -156,9 +156,9 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_UTT_TEXT, &utt_text); bundle_get_str(msg, VC_BUNDLE_CONTINUOUS, &continuous); - if (!strncmp(disp_text, "#NULL", strlen("#NULL") + 1)) + if (!strncmp(disp_text, "#NULL", strlen(disp_text) + 1)) disp_text = NULL; - if (!strncmp(utt_text, "#NULL", strlen("#NULL") + 1)) + if (!strncmp(utt_text, "#NULL", strlen(utt_text) + 1)) utt_text = NULL; if (pid != NULL && continuous != NULL) { @@ -166,7 +166,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_DIALOG */ - else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get Error"); char* reason = NULL; char* daemon_pid = NULL; @@ -177,7 +177,7 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); char* temp_msg = NULL; - if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) { + if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen(err_msg) + 1)) { temp_msg = strdup(err_msg); } @@ -191,7 +191,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_ERROR */ - else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request set private data"); char* tmp_pid = NULL; char* key = NULL; @@ -214,7 +214,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */ - else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT))) { + else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT) + 1)) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request feedback audio format"); char* channel = NULL; char* audio_type = NULL; @@ -264,7 +264,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ bundle_get_str(msg, VC_BUNDLE_METHOD, &method); - if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING))) { + if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING) + 1)) { char *utt_id = NULL; char *event = NULL; char* buffer = NULL; diff --git a/client/vc_tidl.c b/client/vc_tidl.c index f8c03ed..7a89c1e 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -198,9 +198,9 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) bundle_get_str(msg, VC_BUNDLE_METHOD, &method); - if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) { + if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO) + 1)) { } /* VCD_METHOD_HELLO */ - else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { + else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE) + 1)) { /* signal!!! */ char* state = NULL; bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state); @@ -208,12 +208,12 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) __vc_cb_service_state(atoi(state)); } } /* VCD_METHOD_SET_SERVICE_STATE */ - else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT))) { + else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT) + 1)) { SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result"); __vc_cb_result(); } /* VCD_METHOD_RESULT */ - else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID))) { + else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID) + 1)) { /* signal!!! */ char* manager_pid = NULL; bundle_get_str(msg, VC_BUNDLE_MANAGER_PID, &manager_pid); @@ -222,7 +222,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) __vc_cb_manager_pid(atoi(manager_pid)); } } /* VCD_METHOD_SEND_MANAGER_PID */ - else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) { + else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR) + 1)) { /* signal!!! */ char* pid; char* reason; @@ -235,7 +235,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg); __vc_cb_error(atoi(reason), err_msg); } /* VCD_METHOD_ERROR */ - else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { + else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS) + 1)) { /* signal!!! */ char* pid = NULL; char* utt_id = NULL; diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index 1e3acd8..5ea5baf 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -63,7 +63,7 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_METHOD, &method); - if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO))) { + if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO) + 1)) { SLOG(LOG_INFO, TAG_VCW, "@@@ Get widget hello"); bundle_get_str(msg, VC_BUNDLE_PID, &val); if (val) { @@ -73,7 +73,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_METHOD_HELLO */ - else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { + else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE) + 1)) { bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { @@ -83,7 +83,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_METHOD_SET_SERVICE_STATE */ - else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP))) { + else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP) + 1)) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Show / Hide tooltip"); char* temp_show = NULL; bundle_get_str(msg, VC_BUNDLE_PID, &val); @@ -106,13 +106,13 @@ static void __notify_cb(void *user_data, bundle *msg) } } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */ - else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT))) { + else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT) + 1)) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget result"); __vc_widget_cb_result(); } /* VCD_WIDGET_METHOD_RESULT */ - else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR))) { + else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR) + 1)) { SLOG(LOG_INFO, TAG_VCW, "@@@ Get Pre Result"); char* temp_reason = NULL; char* temp_daemon_pid = NULL; diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 6afb62b..cd4a99c 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -142,9 +142,9 @@ static int __vc_db_check_table(sqlite3* db_handle, const char* table, bool *is_e { char* sql = NULL; *is_exist = false; - if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table))) { + if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table) + 1)) { sql = strdup("SELECT COUNT(*) FROM sqlite_master WHERE name='vc_result';"); - } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table))) { + } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table) + 1)) { sql = strdup("SELECT COUNT(*) FROM sqlite_master WHERE name='vc_info';"); } else { return VC_DB_ERROR_INVALID_PARAMETER; @@ -500,7 +500,7 @@ static int __vc_db_get_commands(sqlite3* db_handle, int pid, vc_cmd_type_e type, ret = vc_cmd_get_appid(temp_cmd, &temp_text); if (NULL != appid && 0 == ret) { - if (VC_COMMAND_TYPE_BACKGROUND == type && 0 == strncmp(appid, temp_text, strlen(appid))) { + if (VC_COMMAND_TYPE_BACKGROUND == type && 0 == strncmp(appid, temp_text, strlen(appid) + 1)) { SLOG(LOG_DEBUG, vc_db_tag(), "Skip get background commands when app is foreground, appid(%s)", appid); free(temp_text); @@ -1471,10 +1471,10 @@ static int __vc_db_create_table(sqlite3* db_handle, const char* table) SLOG(LOG_INFO, vc_db_tag(), "[INFO] Create DB table (%s)", table); char* sql = NULL; - if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table))) { + if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table) + 1)) { sql = strdup("CREATE TABLE IF NOT EXISTS vc_result (id INTEGER PRIMARY KEY AUTOINCREMENT, result TEXT, event INTEGER, msg TEXT, exclusive INTEGER,\ pid INTEGER, type INTEGER, format INTEGER, domain INTEGER, command TEXT, parameter TEXT, appid TEXT, invocation_name TEXT, fixed TEXT);"); - } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table))) { + } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table) + 1)) { sql = strdup("CREATE TABLE IF NOT EXISTS vc_info (id INTEGER PRIMARY KEY AUTOINCREMENT, pid INTEGER, type INTEGER, format INTEGER, domain INTEGER, \ command TEXT, parameter TEXT, appid TEXT, invocation_name TEXT, fixed TEXT);"); } else { @@ -1875,9 +1875,9 @@ int __vc_db_delete_table(sqlite3* db_handle, const char* table) free(sql); sql = NULL; - if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table))) { + if (0 == strncmp(table, VC_RESULT_TABLE, strlen(table) + 1)) { sql = strdup("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='vc_result';"); - } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table))) { + } else if (0 == strncmp(table, VC_INFO_TABLE, strlen(table) + 1)) { sql = strdup("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='vc_info';"); } diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c index 4c02835..e1a4f4c 100644 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -280,7 +280,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati return VC_ERROR_OUT_OF_MEMORY; } - if (0 != strncmp(cmd->appid, prev_appid, strlen(cmd->appid))) { + if (0 != strncmp(cmd->appid, prev_appid, strlen(cmd->appid) + 1)) { //delete background commands with appid and type ret = vc_db_delete_commands_without_reset_transaction(cmd->pid, type, cmd->appid); if (VC_ERROR_NONE != ret) { diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 292e347..c917dff 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -71,7 +71,7 @@ int vcd_client_manager_set(int pid) return VCD_ERROR_OPERATION_FAILED; } - if (-1 != g_manager.pid && NULL != g_manager.appid && 0 == strncmp(g_manager.appid, appid, strlen(g_manager.appid))) { + if (-1 != g_manager.pid && NULL != g_manager.appid && 0 == strncmp(g_manager.appid, appid, strlen(g_manager.appid) + 1)) { SLOG(LOG_WARN, TAG_VCD, "Same manager has already registered. It doesn't need to set manager again."); if (appid) free(appid); diff --git a/server/vcd_config.c b/server/vcd_config.c index 2cfa477..501851b 100644 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -35,7 +35,7 @@ static int g_disabled_command_type = 0x00; void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_lang) { - if (NULL != before_lang && NULL != current_lang && strncmp(before_lang, current_lang, strlen(before_lang))) { + if (NULL != before_lang && NULL != current_lang && strncmp(before_lang, current_lang, strlen(before_lang) + 1)) { if (NULL != g_lang_cb) g_lang_cb(current_lang, g_user_data); else diff --git a/server/vcd_server.c b/server/vcd_server.c index 679dbec..bd2e793 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1190,7 +1190,7 @@ static void __vcd_file_clean_up() dirp = readdir(dp); if (NULL != dirp) { - if (!strncmp("vc_", dirp->d_name, strlen("vc_"))) { + if (!strncmp("vc_", dirp->d_name, strlen("vc_") + 1)) { memset(remove_path, 0, 257); snprintf(remove_path, 257, "%s/%s", VC_RUNTIME_INFO_ROOT, dirp->d_name); @@ -2501,7 +2501,7 @@ int vcd_server_set_server_dialog(int pid, const char* app_id, const char* creden } SLOG(LOG_ERROR, TAG_VCD, "[Success] Set server dialog, pid(%d), app_id(%s)", pid, app_id); - if (0 != strncmp(credential, "#NULL", strlen(credential))) { + if (0 != strncmp(credential, "#NULL", strlen(credential) + 1)) { ret = vcd_client_set_server_dialog(pid, true); if (0 != ret) SLOG(LOG_INFO, TAG_VCD, "[Server] Set to true for server dialog, app_id(%s)", app_id); -- 2.34.1