1 Star 0 Fork 19

xuxiaolong/wget

forked from src-openEuler/wget 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
print-row-stats-fix-two-integer-overflows.patch 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
IT砖瓦工 提交于 2020-05-21 15:15 . fix and cleanup code
From e2c0c2fbe5efd5da5524553189e376d53194a037 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Thu, 12 Dec 2019 16:14:57 +0100
Subject: [PATCH] * src/progress.c (print_row_stats): Fix two integer overflows
---
src/progress.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/progress.c b/src/progress.c
index 96d00398..4217c620 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -303,6 +303,9 @@ print_row_stats (struct dot_progress *dp, double dltime, bool last)
/* For last row also count bytes accumulated after last dot */
bytes_displayed += dp->accumulated;
+ if (bytes_displayed < 0)
+ bytes_displayed = 0;
+
if (dp->total_length)
{
/* Round to floor value to provide gauge how much data *has*
@@ -338,9 +341,9 @@ print_row_stats (struct dot_progress *dp, double dltime, bool last)
Belperchinov-Shabanski's "wget-new-percentage" patch. */
if (dp->total_length)
{
- wgint bytes_remaining = dp->total_length - bytes_displayed;
+ wgint bytes_remaining = dp->total_length > bytes_displayed ? dp->total_length - bytes_displayed : 0;
/* The quantity downloaded in this download run. */
- wgint bytes_sofar = bytes_displayed - dp->initial_length;
+ wgint bytes_sofar = bytes_displayed > dp->initial_length ? bytes_displayed - dp->initial_length : 1;
double eta = dltime * bytes_remaining / bytes_sofar;
if (eta < 0)
eta = 0;
--
2.19.1.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xxllp/wget.git
git@gitee.com:xxllp/wget.git
xxllp
wget
wget
master

搜索帮助