Restrict curl protocols
This commit is contained in:
parent
74e1f5484a
commit
f1ff5330d9
@ -9,6 +9,8 @@ You should have received a copy of the GNU General Public License along with thi
|
||||
© 2021 dogeystamp <dogeystamp@disroot.org>
|
||||
*/
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
typedef struct {
|
||||
const char *url;
|
||||
const char *feedName;
|
||||
@ -44,5 +46,9 @@ static const int logLevel = 3;
|
||||
// Use 0 to disable redirects, and -1 for no limit.
|
||||
static const int maxRedirs = 10;
|
||||
|
||||
// Restrict allowed protocols for curl using a bitmask.
|
||||
// For more information: https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html
|
||||
static const int curlProtocols = CURLPROTO_HTTPS | CURLPROTO_HTTP;
|
||||
|
||||
// File extension used for each article.
|
||||
static const char fileExt[] = ".html";
|
||||
|
2
minrss.c
2
minrss.c
@ -93,7 +93,7 @@ finish(char *url, long responseCode)
|
||||
if (responseCode == 200)
|
||||
logMsg(4, "Finished downloading %s\n", url);
|
||||
else if (!responseCode)
|
||||
logMsg(1, "Can not reach %s\n", url);
|
||||
logMsg(1, "Can not reach %s: ensure the protocol is enabled and the site is accessible.\n", url);
|
||||
else
|
||||
logMsg(1, "HTTP %ld for %s\n", responseCode, url);
|
||||
}
|
||||
|
1
net.c
1
net.c
@ -73,6 +73,7 @@ createRequest(const char* url, outputStruct *output)
|
||||
stat = curl_easy_setopt(requestHandle, CURLOPT_WRITEFUNCTION, writeCallback);
|
||||
stat = curl_easy_setopt(requestHandle, CURLOPT_WRITEDATA, (void*)output);
|
||||
stat = curl_easy_setopt(requestHandle, CURLOPT_MAXREDIRS, maxRedirs);
|
||||
stat = curl_easy_setopt(requestHandle, CURLOPT_PROTOCOLS, curlProtocols);
|
||||
stat = curl_easy_setopt(requestHandle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
|
||||
if (stat) {
|
||||
|
Loading…
Reference in New Issue
Block a user