Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions source/protocol/http/curlinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,40 @@ static size_t writeToFile(void *ptr, size_t size, size_t nmemb, void *stream)
return written;
}

static int curl_debug_callback_func(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
{
// Suppress unused parameter warnings
(void)handle;
(void)userptr;

switch (type) {
case CURLINFO_TEXT:
T2Info("curl: %.*s", (int)size, data);
break;
case CURLINFO_HEADER_OUT:
T2Info("curl: => Send header: %.*s", (int)size, data);
break;
case CURLINFO_DATA_OUT:
T2Info("curl: => Send data: %zu bytes", size);
break;
case CURLINFO_SSL_DATA_OUT:
T2Info("curl: => Send SSL data: %zu bytes", size);
break;
case CURLINFO_HEADER_IN:
T2Info("curl: <= Recv header: %.*s", (int)size, data);
break;
case CURLINFO_DATA_IN:
T2Info("curl: <= Recv data: %zu bytes", size);
break;
case CURLINFO_SSL_DATA_IN:
T2Info("curl: <= Recv SSL data: %zu bytes", size);
break;
default:
break;
}
return 0;
}

static T2ERROR setHeader(CURL *curl, const char* destURL, struct curl_slist **headerList, childResponse *childCurlResponse)
{

Expand Down Expand Up @@ -332,7 +366,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid)
pid_t childPid;
int sharedPipeFds[2];

T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);
if(httpUrl == NULL || payload == NULL)
{
return ret;
Expand Down Expand Up @@ -430,7 +464,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid)
}
#endif
pthread_sigmask(SIG_UNBLOCK, &blocking_signal, NULL);
T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return T2ERROR_FAILURE;
}

Expand All @@ -455,6 +489,10 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid)
curl_easy_cleanup(curl); // CID 189985: Resource leak
goto child_cleanReturn;
}
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_debug_callback_func);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, curl_debug_callback_func)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, NULL)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


#ifdef LIBRDKCERTSEL_BUILD
pEngine = rdkcertselector_getEngine(thisCertSel);
if(pEngine != NULL)
Expand Down Expand Up @@ -624,7 +662,7 @@ child_cleanReturn :
ret = T2ERROR_SUCCESS;
T2Info("Report Sent Successfully over HTTP : %ld\n", childCurlResponse.http_code);
}
T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return ret;
}

Expand Down
42 changes: 40 additions & 2 deletions source/xconf-client/xconfclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,40 @@ static size_t httpGetCallBack(void *response, size_t len, size_t nmemb,
return realsize;
}

static int curl_debug_callback_func(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
{
// Suppress unused parameter warnings
(void)handle;
(void)userptr;

switch (type) {
case CURLINFO_TEXT:
T2Info("curl: %.*s", (int)size, data);
break;
case CURLINFO_HEADER_OUT:
T2Info("curl: => Send header: %.*s", (int)size, data);
break;
case CURLINFO_DATA_OUT:
T2Info("curl: => Send data: %zu bytes", size);
break;
case CURLINFO_SSL_DATA_OUT:
T2Info("curl: => Send SSL data: %zu bytes", size);
break;
case CURLINFO_HEADER_IN:
T2Info("curl: <= Recv header: %.*s", (int)size, data);
break;
case CURLINFO_DATA_IN:
T2Info("curl: <= Recv data: %zu bytes", size);
break;
case CURLINFO_SSL_DATA_IN:
T2Info("curl: <= Recv SSL data: %zu bytes", size);
break;
default:
break;
}
return 0;
}

#ifdef LIBRDKCERTSEL_BUILD
void xcCertSelectorFree()
{
Expand Down Expand Up @@ -579,7 +613,7 @@ static void xcCertSelectorInit()
T2ERROR doHttpGet(char* httpsUrl, char **data)
{

T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);

T2Info("%s with url %s \n", __FUNCTION__, httpsUrl);
CURL *curl;
Expand Down Expand Up @@ -706,6 +740,10 @@ T2ERROR doHttpGet(char* httpsUrl, char **data)
{
T2Error("%s : Curl set opts failed with error %s \n", __FUNCTION__, curl_easy_strerror(code));
}
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_debug_callback_func);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, curl_debug_callback_func)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Unchecked return value from library

Calling "curl_easy_setopt(curl, _curl_opt, NULL)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


#if defined(ENABLE_RDKB_SUPPORT) && !defined(RDKB_EXTENDER)

#if defined(WAN_FAILOVER_SUPPORTED) || defined(FEATURE_RDKB_CONFIGURABLE_WAN_INTERFACE)
Expand Down Expand Up @@ -983,7 +1021,7 @@ status_return :
}
}
}
T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return ret;

}
Expand Down
Loading