1 Star 0 Fork 19

xuxiaolong/wget

forked from src-openEuler/wget 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-segfault-in-progress-bar-in-certain-locales.patch 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
IT砖瓦工 提交于 2020-05-21 15:15 . fix and cleanup code
From 6bd74e33d6d0ccc43031405819a6766382823828 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Wed, 18 Dec 2019 13:06:46 +0100
Subject: [PATCH] Fix segfault in progress bar in certain locales
* src/progress.c (create_image): Protect memset from negative count
Reported-by: JunDong Xie
---
src/progress.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/progress.c b/src/progress.c
index 80775b0c..63bebab8 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -1099,8 +1099,11 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
/* " 234.56M" */
down_size = human_readable (size, 1000, 2);
cols_diff = PROGRESS_FILESIZE_LEN - count_cols (down_size);
- memset (p, ' ', cols_diff);
- p += cols_diff;
+ if (cols_diff > 0)
+ {
+ memset (p, ' ', cols_diff);
+ p += cols_diff;
+ }
p += sprintf (p, "%s", down_size);
/* " 12.52Kb/s or 12.52KB/s" */
@@ -1182,8 +1185,11 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
else
ncols += sprintf (p + nbytes, "%ss", print_decimal (dl_total_time));
p += ncols + bytes_cols_diff;
- memset (p, ' ', PROGRESS_ETA_LEN - ncols);
- p += PROGRESS_ETA_LEN - ncols;
+ if (ncols < PROGRESS_ETA_LEN)
+ {
+ memset (p, ' ', PROGRESS_ETA_LEN - ncols);
+ p += PROGRESS_ETA_LEN - ncols;
+ }
}
padding = bp->width - count_cols (bp->buffer);
--
2.19.1.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xxllp/wget.git
git@gitee.com:xxllp/wget.git
xxllp
wget
wget
master

搜索帮助