wget/fix-ub-print-row-stats-if-eta-negative.patch
2020-05-21 15:15:15 +08:00

26 lines
927 B
Diff

From abe1ab191698f4e3e337b5436c7060a0e4d103d7 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Thu, 12 Dec 2019 13:53:44 +0100
Subject: [PATCH] * src/progress.c (print_row_stats): Fix UB if eta < 0
---
src/progress.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/progress.c b/src/progress.c
index d2778d41..06750531 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -327,6 +327,8 @@ print_row_stats (struct dot_progress *dp, double dltime, bool last)
/* The quantity downloaded in this download run. */
wgint bytes_sofar = bytes_displayed - dp->initial_length;
double eta = dltime * bytes_remaining / bytes_sofar;
+ if (eta < 0)
+ eta = 0;
if (eta < INT_MAX - 1)
logprintf (LOG_PROGRESS, " %s",
eta_to_human_short ((int) (eta + 0.5), true));
--
2.19.1.windows.1