Skip to content

Commit

Permalink
clamonacc: Fix stack buffer overflow with old curl
Browse files Browse the repository at this point in the history
curl_easy_getinfo expects a long for CURLINFO_ACTIVESOCKET, but
curl_socket_t is an int, which was causing a stack buffer overflow
and crash.
  • Loading branch information
epozuelo authored and micahsnyder committed Dec 9, 2020
1 parent 38f8741 commit 2b46876
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions clamonacc/client/communication.c
Expand Up @@ -87,7 +87,9 @@ int onas_sendln(CURL *curl, const void *line, size_t len, int64_t timeout)
curlcode = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
#else
/* Use deprecated CURLINFO_LASTSOCKET option */
curlcode = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
long long_sockfd;
curlcode = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &long_sockfd);
sockfd = (curl_socket_t) long_sockfd;
#endif

if (CURLE_OK != curlcode) {
Expand Down Expand Up @@ -152,7 +154,9 @@ int onas_recvln(struct onas_rcvln *rcv_data, char **ret_bol, char **ret_eol, int
rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_ACTIVESOCKET, &sockfd);
#else
/* Use deprecated CURLINFO_LASTSOCKET option */
rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_LASTSOCKET, &sockfd);
long long_sockfd;
rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_LASTSOCKET, &long_sockfd);
sockfd = (curl_socket_t) long_sockfd;
#endif

if (CURLE_OK != rcv_data->curlcode) {
Expand Down

0 comments on commit 2b46876

Please sign in to comment.