diff options
Diffstat (limited to 'src/lib/internet.cc')
| -rw-r--r-- | src/lib/internet.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/internet.cc b/src/lib/internet.cc index 99ae5c214..1c61e96e3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -24,11 +24,11 @@ #include <curl/curl.h> #include <zip.h> #include "util.h" +#include "safe_stringstream.h" #include "i18n.h" using std::string; -using std::stringstream; using std::list; using boost::optional; using boost::function; @@ -56,6 +56,8 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); + /* Maximum time is 20s */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); CURLcode const cr = curl_easy_perform (curl); @@ -117,6 +119,8 @@ ftp_ls (string url) url += "/"; } curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); + /* 20s timeout */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); string ls_raw; struct curl_slist* commands = 0; @@ -130,11 +134,10 @@ ftp_ls (string url) return list<string> (); } - stringstream s (ls_raw); - string line; + SafeStringStream s (ls_raw); list<string> ls; while (s.good ()) { - getline (s, line); + string const line = s.getline (); if (line.length() > 55) { string const file = line.substr (55); if (file != "." && file != "..") { |
