From: alkasethi Date: Fri, 11 Jan 2019 11:33:08 +0000 (+0530) Subject: [SATDEVKIT-2522]Security issues handled X-Git-Tag: submit/tizen/20190114.083139^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=877ce6726b20f05e0b1b4f8e5c3ca09ce264ac23;p=sdk%2Ftarget%2Fsdbd.git [SATDEVKIT-2522]Security issues handled Change-Id: I41924e10ade8d96fcefa8adc053a12c0f6078a71 Signed-off-by: alkasethi --- diff --git a/src/plugin.c b/src/plugin.c index 2e495e9..3c2533c 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -388,9 +388,11 @@ int request_capability_to_plugin ( int cap, char* out_buf, unsigned int out_len ret = request_sync_cmd ( PLUGIN_SYNC_CMD_CAPABILITY, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { - strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); - out_buf[out_len - 1] = '\0'; - success = 1; + if(out.array_of_parameter[0].v_string.data != NULL) { + strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); + out_buf[out_len - 1] = '\0'; + success = 1; + } release_parameters ( &out ); D ("request capability success : %s\n", out_buf); @@ -501,9 +503,11 @@ int request_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, u ret = request_sync_cmd ( cmd, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { - strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); - out_buf[out_len - 1] = '\0'; - success = 1; + if(out.array_of_parameter[0].v_string.data != NULL) { + strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); + out_buf[out_len - 1] = '\0'; + success = 1; + } release_parameters ( &out ); } @@ -539,9 +543,11 @@ int request_extcmd_conversion_to_plugin ( int cmd, const char* in_buf, char* out ret = plugin_sync_proc ( cmd, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { - strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); - out_buf[out_len - 1] = '\0'; - success = 1; + if(out.array_of_parameter[0].v_string.data != NULL) { + strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); + out_buf[out_len - 1] = '\0'; + success = 1; + } release_parameters ( &out ); } diff --git a/src/services.c b/src/services.c index 03e2751..db9148e 100644 --- a/src/services.c +++ b/src/services.c @@ -1417,7 +1417,7 @@ int request_extcmd_to_plugin(const char* in_buf) { full_cmd[ENV_BUF_MAX - 1] = '\0'; } else { - strcat(full_cmd, cmd_name); + strncat(full_cmd, cmd_name, strlen(cmd_name)); } int i = 1; @@ -1425,8 +1425,8 @@ int request_extcmd_to_plugin(const char* in_buf) { if (strlen(full_cmd) + strlen(tokens[i]) + 1 >= ENV_BUF_MAX) { break; } - strcat(full_cmd, " "); - strcat(full_cmd, tokens[i]); + strncat(full_cmd, " ",1); + strncat(full_cmd, tokens[i], strlen(tokens[i])); } D("full extcmd: %s\n", full_cmd); if (!strcmp(exec_type, "sync")) {