From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id E0E6F3858D1E for ; Wed, 29 Mar 2023 15:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0E6F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1031.google.com with SMTP id o6-20020a17090a9f8600b0023f32869993so18838920pjp.1 for ; Wed, 29 Mar 2023 08:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680102179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bG1yKadX7pLxgqbDK6l9kyT13epkVUlKQqcjkw9O8gA=; b=QH1rEY+jCtobLxGrqgYw1c81Mqw2qbS0jM1y5eBAUDJQ5UrblEioGaM07NIC5eiWMV OkYQ1ip3kM17nfQ1jle1F7w3oOH+YzMlSL00GydfU1EO3yn53zLBWSlObeEVpeN+wOOg IXS1S+NiRIPm9paWNDYQO2s3WR2mEqIdSUuV9vDeun1Xu0rP4ofBkgCGPfyREVfEBXyH VqKCf/F9v4kMrKWB40NIn/eIgLS6oDihAvVnr6z47NoweVsIVj7PRSH1tLAyMZX/lGgH AML4l1Mi/C3OQxkt/ve5h062XpboTKgun/Kq3L3Z82lrYlOsX485L+B144l0JEO1UahA ao9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680102179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bG1yKadX7pLxgqbDK6l9kyT13epkVUlKQqcjkw9O8gA=; b=h6d2gi81c7d1Nus51Dxsc9x0A3DH1P2ihjmD0QtUB4zZM5vtzWjYjQ/umOo7pDMQwT sdMOOTAb0YJOhiQxrGJ1bXgOOZQi4KJHQZ5vUd9K/nBYiRdwflGqmfuS8TUpCV1Q7shp iD5bu4XiHbsl+io0Ual/tCubWdydB/vBEenLg0IULoJ/0o632YiLmIrefQHqsnc/PHLb gujrDpNwg0saceAWSMPF8NIZ4JKhzJRG3gwkDzAakE46/nOYD2hw6rahLlmAqoyxY+oT vRFBYV/jEzpX1MqAOb7aIdqPEoP+hOM05vf8LolbbKPgOyYtsLeaSROWAtbmrcsBAHax 7RuQ== X-Gm-Message-State: AAQBX9e+KFLiklTt+/HJx9SuqBWlVf70KoWbgY+IG7iPRRimGwuJ3bEp YR9KD3pRvxHefPv82nsPYoAHtaF8rZiPEPy3A0U= X-Google-Smtp-Source: AKy350ajToo1CnJlRUI63fcEWfwIq0l+XYD61AdtwTXChZnlsL9lfLLHehr39H4/uheA+g4TNFJ5+g== X-Received: by 2002:a17:90b:3ec1:b0:22c:6d7c:c521 with SMTP id rm1-20020a17090b3ec100b0022c6d7cc521mr21647644pjb.45.1680102179443; Wed, 29 Mar 2023 08:02:59 -0700 (PDT) Received: from localhost ([2a0c:b641:69c:e9b8:1::1]) by smtp.gmail.com with ESMTPSA id o11-20020a17090a678b00b00233b18e6fb3sm1531187pjj.1.2023.03.29.08.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 08:02:59 -0700 (PDT) From: lilydjwg To: elfutils-devel@sourceware.org Cc: lilydjwg Subject: [PATCH v2 1/2] debuginfod-client.c: Fix download size not correctly fallbacks to x-debuginfod-size header Date: Wed, 29 Mar 2023 23:02:36 +0800 Message-Id: <20230329150237.896092-1-lilydjwg@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Signed-off-by: lilydjwg --- ChangeLog | 5 +++++ debuginfod/debuginfod-client.c | 6 +++--- 2 files changed, 8 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/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; -- 2.40.0