From d61545a188a1ab0d8dcbd653c358ac2187a97f9b Mon Sep 17 00:00:00 2001 From: Bang Kwang-Min Date: Thu, 9 May 2013 13:27:33 +0900 Subject: [PATCH] fix the segmentation fault if call download_get_url() without calling download_create() [issue#] failure in Tizen Compliance Tests [cause] refer uninitialized variable [solution] use it after connecting to provider Change-Id: I3c51dbf5dd6cc0654bf5861bc0b0c2c8d74dd6dd --- provider-interface/download-provider-interface.c | 40 +++++++----------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/provider-interface/download-provider-interface.c b/provider-interface/download-provider-interface.c index 499c2af..9621922 100755 --- a/provider-interface/download-provider-interface.c +++ b/provider-interface/download-provider-interface.c @@ -882,12 +882,6 @@ static dp_error_type __dp_interface_set_string (const int id, const dp_command_type cmd, const char *value) { dp_error_type errorcode = DP_ERROR_NONE; - int fd = g_interface_info->cmd_socket; - - if (fd < 0) { - TRACE_ERROR("[CHECK SOCKET]"); - return DOWNLOAD_ADAPTOR_ERROR_IO_ERROR; - } if (value == NULL || strlen(value) <= 0) { TRACE_ERROR("[CHECK url]"); return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER; @@ -903,6 +897,8 @@ static dp_error_type __dp_interface_set_string DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + // send commnad with ID errorcode = __ipc_send_command(fd, id, cmd); if (errorcode == DP_ERROR_NONE) { @@ -925,12 +921,6 @@ static dp_error_type __dp_interface_set_strings const unsigned count) { dp_error_type errorcode = DP_ERROR_NONE; - int fd = g_interface_info->cmd_socket; - - if (fd < 0) { - TRACE_ERROR("[CHECK SOCKET]"); - return DOWNLOAD_ADAPTOR_ERROR_IO_ERROR; - } if (strings == NULL || count == 0) { TRACE_ERROR("[CHECK strings]"); return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER; @@ -946,6 +936,8 @@ static dp_error_type __dp_interface_set_strings DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + // send commnad with ID errorcode = __ipc_send_command(fd, id, cmd); if (errorcode == DP_ERROR_NONE) { @@ -976,13 +968,8 @@ static dp_error_type __dp_interface_get_string (const int id, const dp_command_type cmd, char **value) { int errorcode = DP_ERROR_NONE; - int fd = g_interface_info->cmd_socket; char *recv_str = NULL; - if (fd < 0) { - TRACE_ERROR("[CHECK SOCKET]"); - return DOWNLOAD_ADAPTOR_ERROR_IO_ERROR; - } if (value == NULL) { TRACE_ERROR("[CHECK buffer]"); return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER; @@ -998,6 +985,8 @@ static dp_error_type __dp_interface_get_string DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + errorcode = __ipc_send_command_return(id, cmd); if (errorcode == DP_ERROR_NONE) { // getting state with ID from provider. @@ -1019,15 +1008,10 @@ static dp_error_type __dp_interface_get_strings const unsigned length, char ***values, unsigned *count) { int errorcode = DP_ERROR_NONE; - int fd = g_interface_info->cmd_socket; int i = 0; int recv_str_index = 0; char **recv_strings = NULL; - if (fd < 0) { - TRACE_ERROR("[CHECK SOCKET]"); - return DOWNLOAD_ADAPTOR_ERROR_IO_ERROR; - } if (values == NULL || count == NULL) { TRACE_ERROR("[CHECK buffer]"); return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER; @@ -1043,6 +1027,8 @@ static dp_error_type __dp_interface_get_strings DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + errorcode = __ipc_send_command(fd, id, cmd); if (errorcode == DP_ERROR_NONE) { if (length > 0 && strings != NULL) { @@ -1105,12 +1091,7 @@ static dp_error_type __dp_interface_get_int { int errorcode = DP_ERROR_NONE; int recv_int = -1; - int fd = g_interface_info->cmd_socket; - if (fd < 0) { - TRACE_ERROR("[CHECK SOCKET]"); - return DOWNLOAD_ADAPTOR_ERROR_IO_ERROR; - } if (value == NULL) { TRACE_ERROR("[CHECK buffer]"); return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER; @@ -1126,6 +1107,8 @@ static dp_error_type __dp_interface_get_int DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + errorcode = __ipc_send_command_return(id, cmd); if (errorcode == DP_ERROR_NONE) { recv_int = __ipc_read_int(fd); @@ -1147,7 +1130,6 @@ static dp_error_type __dp_interface_set_int (const int id, dp_command_type cmd, const int value) { int errorcode = DP_ERROR_NONE; - int fd = g_interface_info->cmd_socket; DP_PRE_CHECK_ID; @@ -1159,6 +1141,8 @@ static dp_error_type __dp_interface_set_int DP_CHECK_PROVIDER_STATUS; + int fd = g_interface_info->cmd_socket; + // send commnad with ID errorcode = __ipc_send_command(fd, id, cmd); if (errorcode == DP_ERROR_NONE) { -- 2.7.4