From 542524855a46d66f18439688ffe61177cc867266 Mon Sep 17 00:00:00 2001 From:Tim Rühsen Date: Thu, 12 Dec 2019 13:47:30 +0100 Subject: [PATCH] * src/progress.c (dot_update, dot_finish): Sanitize input --- src/progress.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/progress.c b/src/progress.c index 574a035e..d2778d41 100644 --- a/src/progress.c +++ b/src/progress.c @@ -348,6 +348,15 @@ print_row_stats (struct dot_progress *dp, double dltime, bool last) static void dot_update (void *progress, wgint howmuch, double dltime) { + // sanitize input + if (dltime >= INT_MAX) + dltime = INT_MAX - 1; + else if (dltime < 0) + dltime = 0; + + if (howmuch < 0) + howmuch = 0; + struct dot_progress *dp = progress; dp->accumulated += howmuch; dp->dltime = dltime; @@ -406,6 +415,12 @@ dot_finish (void *progress, double dltime) logputs (LOG_PROGRESS, " "); } + // sanitize input + if (dltime >= INT_MAX) + dltime = INT_MAX - 1; + else if (dltime < 0) + dltime = 0; + print_row_stats (dp, dltime, true); logputs (LOG_VERBOSE, "\n\n"); log_set_flush (false); -- 2.19.1.windows.1