From 6beb0eeea17cd6cc71cb69737ac63861a8f18d4e Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 29 Aug 2014 23:48:03 +0200 Subject: Ensure progress.size_dl/progress.size_ul are always >= 0 Historically the default "unknown" value for progress.size_dl and progress.size_ul has been zero, since these values are initialized implicitly by the calloc that allocates the curl handle that these variables are a part of. Users of curl that install progress callbacks may expect these values to always be >= 0. Currently it is possible for progress.size_dl and progress.size_ul to by set to a value of -1, if Curl_pgrsSetDownloadSize() or Curl_pgrsSetUploadSize() are passed a "size" of -1 (which a few places currently do, and a following patch will add more). So lets update Curl_pgrsSetDownloadSize() and Curl_pgrsSetUploadSize() so they make sure that these variables always contain a value that is >= 0. Updates test579 and test599. Signed-off-by: Brandon Casey --- tests/libtest/lib599.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index 6b092677a..08c536c72 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -43,6 +43,7 @@ int test(char *URL) { CURL *curl; CURLcode res=CURLE_OK; + double content_length = 0.0; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -74,6 +75,17 @@ int test(char *URL) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + if (!res) { + FILE *moo; + res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, + &content_length); + moo = fopen(libtest_arg2, "wb"); + if (moo) { + fprintf(moo, "CL: %.0f\n", content_length); + fclose(moo); + } + } + test_cleanup: /* always cleanup */ -- cgit v1.2.1