[collectd] [PATCH] Add protection from infinite redirect loops to curl-using plugins

Dan Fandrich dan at coneharvesters.com
Mon Feb 4 23:27:26 CET 2013


---
 src/apache.c |    1 +
 src/ascent.c |    1 +
 src/bind.c   |    1 +
 src/curl.c   |    1 +
 src/nginx.c  |    1 +
 5 files changed, 5 insertions(+)

diff --git a/src/apache.c b/src/apache.c
index 202b73c..e562138 100644
--- a/src/apache.c
+++ b/src/apache.c
@@ -426,6 +426,7 @@ static int init_host (apache_t *st) /* {{{ */
 
 	curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
 	curl_easy_setopt (st->curl, CURLOPT_FOLLOWLOCATION, 1L);
+	curl_easy_setopt (st->curl, CURLOPT_MAXREDIRS, 50L);
 
 	if (st->verify_peer != 0)
 	{
diff --git a/src/ascent.c b/src/ascent.c
index 3a7c393..2378386 100644
--- a/src/ascent.c
+++ b/src/ascent.c
@@ -562,6 +562,7 @@ static int ascent_init (void) /* {{{ */
 
   curl_easy_setopt (curl, CURLOPT_URL, url);
   curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
+  curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L);
 
   if ((verify_peer == NULL) || IS_TRUE (verify_peer))
     curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1L);
diff --git a/src/bind.c b/src/bind.c
index 288949a..7857a67 100644
--- a/src/bind.c
+++ b/src/bind.c
@@ -1399,6 +1399,7 @@ static int bind_init (void) /* {{{ */
   curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
   curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
   curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
+  curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L);
 
   return (0);
 } /* }}} int bind_init */
diff --git a/src/curl.c b/src/curl.c
index 69a5b95..30d6e45 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -378,6 +378,7 @@ static int cc_page_init_curl (web_page_t *wp) /* {{{ */
   curl_easy_setopt (wp->curl, CURLOPT_ERRORBUFFER, wp->curl_errbuf);
   curl_easy_setopt (wp->curl, CURLOPT_URL, wp->url);
   curl_easy_setopt (wp->curl, CURLOPT_FOLLOWLOCATION, 1L);
+  curl_easy_setopt (wp->curl, CURLOPT_MAXREDIRS, 50L);
 
   if (wp->user != NULL)
   {
diff --git a/src/nginx.c b/src/nginx.c
index b76f25b..ecfb307 100644
--- a/src/nginx.c
+++ b/src/nginx.c
@@ -144,6 +144,7 @@ static int init (void)
   }
 
   curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
+  curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L);
 
   if ((verify_peer == NULL) || IS_TRUE (verify_peer))
   {
-- 
1.7.10




More information about the collectd mailing list