[WGID 101577] Replace sprintf with snprintf 60/75160/2 accepted/tizen/common/20160617.121937 accepted/tizen/mobile/20160620.024151 accepted/tizen/wearable/20160620.024245 submit/tizen/20160617.081742
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 17 Jun 2016 02:06:06 +0000 (11:06 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Fri, 17 Jun 2016 02:19:39 +0000 (11:19 +0900)
Change-Id: Ieedbf043a3f9383644aed154a1527de8a68aabad
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/http.h
packaging/capi-network-http.spec
src/http_transaction.c

index 2e2a137..d5d1527 100644 (file)
@@ -1008,7 +1008,7 @@ int http_transaction_get_http_auth_scheme(http_transaction_h http_transaction, h
  * @since_tizen 3.0
  * @remarks The @a realm should be freed using free().
  * @param[in]  http_transaction  The http transaction handle
- * @param[out] realm    The http realm value
+ * @param[out] realm    The http authentication realm value
  * @return 0 on success, otherwise negative error value
  * @retval  #HTTP_ERROR_NONE  Successful
  * @retval  #HTTP_ERROR_INVALID_PARAMETER  Invalid parameter
index 9c52973..2db5826 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-http
 Summary:       Http Framework
-Version:       0.0.8
+Version:       0.0.9
 Release:       0
 Group:         System/Network
 License:       Apache-2.0
index 9a0eed0..11689da 100644 (file)
@@ -271,27 +271,31 @@ int _transaction_submit(gpointer user_data)
                gchar *user_name = NULL;
                gchar *password = NULL;
                gchar *credentials = NULL;
+               int credentials_len = 0;
 
                http_transaction_get_credentials(transaction, &user_name, &password);
-               credentials = (gchar *)malloc(sizeof(gchar) * (strlen(user_name) + 1 + strlen(password) + 1));
-               sprintf(credentials, "%s:%s", (gchar*)user_name, (gchar*)password);
-               free(user_name);
-               free(password);
+               credentials_len = sizeof(gchar) * (strlen(user_name) + 1 + strlen(password) + 1);
+               credentials = (gchar *)malloc(credentials_len);
+               if (credentials) {
+                       snprintf(credentials, credentials_len, "%s:%s", (gchar*)user_name, (gchar*)password);
+                       free(user_name);
+                       free(password);
 
-               http_transaction_get_http_auth_scheme(transaction, &auth_scheme);
+                       http_transaction_get_http_auth_scheme(transaction, &auth_scheme);
 
-               curl_auth_scheme = _get_http_curl_auth_scheme(auth_scheme);
+                       curl_auth_scheme = _get_http_curl_auth_scheme(auth_scheme);
 
-               if (transaction->proxy_auth_type) {
+                       if (transaction->proxy_auth_type) {
 
-                       curl_easy_setopt(transaction->easy_handle, CURLOPT_PROXYAUTH, curl_auth_scheme);
-                       curl_easy_setopt(transaction->easy_handle, CURLOPT_PROXYUSERPWD, credentials);
+                               curl_easy_setopt(transaction->easy_handle, CURLOPT_PROXYAUTH, curl_auth_scheme);
+                               curl_easy_setopt(transaction->easy_handle, CURLOPT_PROXYUSERPWD, credentials);
 
-               } else {
-                       curl_easy_setopt(transaction->easy_handle, CURLOPT_HTTPAUTH, curl_auth_scheme);
-                       curl_easy_setopt(transaction->easy_handle, CURLOPT_USERPWD, credentials);
+                       } else {
+                               curl_easy_setopt(transaction->easy_handle, CURLOPT_HTTPAUTH, curl_auth_scheme);
+                               curl_easy_setopt(transaction->easy_handle, CURLOPT_USERPWD, credentials);
+                       }
+                       free(credentials);
                }
-               free(credentials);
        }
        //LCOV_EXCL_STOP