limit redirects

This commit is contained in:
Christian Grothoff 2020-02-29 16:54:58 +01:00
parent 0a2b049864
commit cdc8c5b57b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
14 changed files with 20 additions and 14 deletions

View File

@ -30,7 +30,7 @@
* @param url URL to query
*/
CURL *
TEL_curl_easy_get (const char *url)
TALER_EXCHANGE_curl_easy_get_ (const char *url)
{
CURL *eh;
@ -43,6 +43,12 @@ TEL_curl_easy_get (const char *url)
curl_easy_setopt (eh,
CURLOPT_FOLLOWLOCATION,
1L));
/* limit MAXREDIRS to 5 as a simple security measure against
a potential infinite loop caused by a malicious target */
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_MAXREDIRS,
5L));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_TCP_FASTOPEN,

View File

@ -36,6 +36,6 @@
* @param url URL to query
*/
CURL *
TEL_curl_easy_get (const char *url);
TALER_EXCHANGE_curl_easy_get_ (const char *url);
#endif /* _TALER_CURL_DEFAULTS_H */

View File

@ -626,7 +626,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
dh->dki.key.rsa_public_key = NULL; /* lifetime not warranted, so better
not copy the pointer */
eh = TEL_curl_easy_get (dh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (dh->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&dh->ctx,
eh,

View File

@ -366,7 +366,7 @@ TALER_EXCHANGE_deposits_get (struct TALER_EXCHANGE_Handle *exchange,
dwh->depconf.h_contract_terms = *h_contract_terms;
dwh->depconf.coin_pub = *coin_pub;
eh = TEL_curl_easy_get (dwh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (dwh->url);
ctx = TEAH_handle_to_context (exchange);
dwh->job = GNUNET_CURL_job_add (ctx,
eh,

View File

@ -1953,7 +1953,7 @@ request_keys (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting keys with URL `%s'.\n",
kr->url);
eh = TEL_curl_easy_get (kr->url);
eh = TALER_EXCHANGE_curl_easy_get_ (kr->url);
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_VERBOSE,

View File

@ -455,7 +455,7 @@ TALER_EXCHANGE_link (struct TALER_EXCHANGE_Handle *exchange,
lh->coin_priv = *coin_priv;
lh->url = TEAH_path_to_url (exchange,
arg_str);
eh = TEL_curl_easy_get (lh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (lh->url);
ctx = TEAH_handle_to_context (exchange);
lh->job = GNUNET_CURL_job_add (ctx,
eh,

View File

@ -456,7 +456,7 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange,
mh->md = md;
mh->url = TEAH_path_to_url (exchange,
arg_str);
eh = TEL_curl_easy_get (mh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (mh->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&mh->ctx,
eh,

View File

@ -389,7 +389,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
ph->url = TEAH_path_to_url (exchange,
arg_str);
ph->was_refreshed = was_refreshed;
eh = TEL_curl_easy_get (ph->url);
eh = TALER_EXCHANGE_curl_easy_get_ (ph->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&ph->ctx,
eh,

View File

@ -461,7 +461,7 @@ TALER_EXCHANGE_refreshes_reveal (struct TALER_EXCHANGE_Handle *exchange,
rrh->url = TEAH_path_to_url (rrh->exchange,
arg_str);
eh = TEL_curl_easy_get (rrh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (rrh->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&rrh->ctx,
eh,

View File

@ -387,7 +387,7 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
TALER_amount_hton (&rh->depconf.refund_fee,
refund_fee);
eh = TEL_curl_easy_get (rh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (rh->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&rh->ctx,
eh,

View File

@ -274,7 +274,7 @@ TALER_EXCHANGE_reserves_get (struct TALER_EXCHANGE_Handle *exchange,
rgh->reserve_pub = *reserve_pub;
rgh->url = TEAH_path_to_url (exchange,
arg_str);
eh = TEL_curl_easy_get (rgh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (rgh->url);
ctx = TEAH_handle_to_context (exchange);
rgh->job = GNUNET_CURL_job_add (ctx,
eh,

View File

@ -366,7 +366,7 @@ TALER_EXCHANGE_transfers_get (struct TALER_EXCHANGE_Handle *exchange,
}
wdh->url = TEAH_path_to_url (wdh->exchange,
arg_str);
eh = TEL_curl_easy_get (wdh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (wdh->url);
ctx = TEAH_handle_to_context (exchange);
wdh->job = GNUNET_CURL_job_add (ctx,
eh,

View File

@ -407,7 +407,7 @@ TALER_EXCHANGE_wire (struct TALER_EXCHANGE_Handle *exchange,
wh->cb_cls = wire_cb_cls;
wh->url = TEAH_path_to_url (exchange, "/wire");
eh = TEL_curl_easy_get (wh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (wh->url);
ctx = TEAH_handle_to_context (exchange);
wh->job = GNUNET_CURL_job_add (ctx,
eh,

View File

@ -426,7 +426,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
wh->ps = *ps;
wh->url = TEAH_path_to_url (exchange,
arg_str);
eh = TEL_curl_easy_get (wh->url);
eh = TALER_EXCHANGE_curl_easy_get_ (wh->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&wh->ctx,
eh,