From 328977cfec1c5f370043d27b64ded201da95a380 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 8 Feb 2013 17:59:11 +0300 Subject: Block any protocols in curl except HTTP and HTTPS. --- src/gui/whoisonline.cpp | 1 + src/net/download.cpp | 9 +++++++++ src/net/download.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index ed3d038a7..df2e5a47e 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -516,6 +516,7 @@ int WhoIsOnline::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 7); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); Net::Download::addProxy(curl); + Net::Download::secureCurl(curl); struct curl_slist *pHeaders = nullptr; // Make sure the resources2.txt and news.txt aren't cached, diff --git a/src/net/download.cpp b/src/net/download.cpp index 7fb799fa0..838038f7c 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -253,6 +253,7 @@ int Download::downloadThread(void *ptr) curl_easy_setopt(d->mCurl, CURLOPT_CONNECTTIMEOUT, 30); curl_easy_setopt(d->mCurl, CURLOPT_TIMEOUT, 1800); addProxy(d->mCurl); + secureCurl(d->mCurl); if ((res = curl_easy_perform(d->mCurl)) != 0 && !d->mOptions.cancel) @@ -410,4 +411,12 @@ void Download::addProxy(CURL *curl) } } +void Download::secureCurl(CURL *curl) +{ + curl_easy_setopt(curl, CURLOPT_PROTOCOLS, + CURLPROTO_HTTP | CURLPROTO_HTTPS); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, + CURLPROTO_HTTP | CURLPROTO_HTTPS); +} + } // namespace Net diff --git a/src/net/download.h b/src/net/download.h index 77f1d1ccc..f9f842588 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -97,6 +97,8 @@ class Download final static void addProxy(CURL *curl); + static void secureCurl(CURL *curl); + private: static int downloadThread(void *ptr); static int downloadProgress(void *clientp, double dltotal, -- cgit v1.2.3-70-g09d2