Use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T for curl_easy_getinfo() (added in curl 7.55.0) to get the length of a remote file, instead of the old CURLINFO_CONTENT_LENGTH_DOWNLOAD. This way the size is already a 64-bit integer value, as opposed to a double (the old information). --- plugins/curl/curl.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c index 1b0d2b9..e0449b7 100644 --- a/plugins/curl/curl.c +++ b/plugins/curl/curl.c @@ -70,6 +70,10 @@ static long protocols = CURLPROTO_ALL; /* Use '-D curl.verbose=1' to set. */ int curl_debug_verbose = 0; +#if CURL_AT_LEAST_VERSION(7, 55, 0) +#define HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T +#endif + static void curl_load (void) { @@ -290,6 +294,9 @@ curl_open (int readonly) struct curl_handle *h; CURLcode r; double d; +#ifdef HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T + curl_off_t o; +#endif h = calloc (1, sizeof *h); if (h == NULL) { @@ -377,6 +384,21 @@ curl_open (int readonly) goto err; } +#ifdef HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T + r = curl_easy_getinfo (h->c, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &o); + if (r != CURLE_OK) { + display_curl_error (h, r, "could not get length of remote file [%s]", url); + goto err; + } + + if (o == -1) { + nbdkit_error ("could not get length of remote file [%s], " + "is the URL correct?", url); + goto err; + } + + h->exportsize = o; +#else r = curl_easy_getinfo (h->c, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d); if (r != CURLE_OK) { display_curl_error (h, r, "could not get length of remote file [%s]", url); @@ -390,6 +412,7 @@ curl_open (int readonly) } h->exportsize = (size_t) d; +#endif nbdkit_debug ("content length: %" PRIi64, h->exportsize); if (strncasecmp (url, "http://", strlen ("http://")) == 0 || -- 2.24.1