From a9bf65487df83c7b4ebbab4ff77b57e0c17f7c33 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 29 Mar 2023 23:02:36 +0800 Subject: debuginfod-client.c: Fix download size not correctly fallbacks to x-debuginfod-size header Signed-off-by: lilydjwg --- ChangeLog | 5 +++++ debuginfod/ChangeLog | 6 ++++++ debuginfod/debuginfod-client.c | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10c23002..05697a02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-03-29 lilydjwg + + * debuginfod/debuginfod-client.c: Fix download size not correctly + fallbacks to x-debuginfod-size header + 2023-03-03 Mark Wielaard * NEWS: Add ELFCOMPRESS_ZSTD support for libelf and elfcompress. diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 5db5a753..a8d264b5 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,9 @@ +2023-03-29 lilydjwg + + * debuginfod-client.c (debuginfod_query_server): Handle dl_size in + progress to account for possible curl 8.0.1 changes to + CURLINFO_CONTENT_LENGTH_DOWNLOAD*. + 2023-03-17 Aaron Merey * debuginfod-client.c (debuginfod_query_server): Do not create an diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index b33408eb..d6d3f0dd 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1467,7 +1467,7 @@ debuginfod_query_server (debuginfod_client *c, goto out2; } - long dl_size = 0; + long dl_size = -1; if (target_handle && (c->progressfn || maxsize > 0)) { /* Get size of file being downloaded. NB: If going through @@ -1486,7 +1486,7 @@ debuginfod_query_server (debuginfod_client *c, curl_res = curl_easy_getinfo(target_handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl); - if (curl_res == CURLE_OK) + if (curl_res == CURLE_OK && cl >= 0) dl_size = (cl >= (double)(LONG_MAX+1UL) ? LONG_MAX : (long)cl); #endif /* If Content-Length is -1, try to get the size from @@ -1527,7 +1527,7 @@ debuginfod_query_server (debuginfod_client *c, } - if ((*c->progressfn) (c, pa, dl_size)) + if ((*c->progressfn) (c, pa, dl_size == -1 ? 0 : dl_size)) { c->progressfn_cancel = true; break; -- cgit v1.2.1