summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2022-01-12 19:50:58 -0800
committerWayne Davison <wayne@opencoder.net>2022-01-12 20:04:32 -0800
commit8c4ceb3b86749523573fec0df38a3b315575735c (patch)
treeb096918ae9a8734f4eb2b2d2de41e4704ed8fa5d
parent30a590954416fa0ab2a2b27cd8098b310794446d (diff)
downloadrsync-8c4ceb3b86749523573fec0df38a3b315575735c.tar.gz
Avoid a -8 in the progress output's remaining time
If the double "remain" value is so large that it overflows an int, make the estimated seconds output as :00 instead of :-8. Similar for the estimated remaining minutes. Support larger hours values.
-rw-r--r--NEWS.md5
-rw-r--r--progress.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/NEWS.md b/NEWS.md
index 8bab61cf..4eebaa44 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -88,6 +88,11 @@
check to see if the allowed time is over, which should make rsync exit more
consistently.
+ - Tweak the snprintf() in progress.c that turns the remaining time into a
+ HHHH:MM:SS value to avoid putting a -8 into the SS or MM spots when the
+ remaining seconds is so large that it overflows the integer arithmetic
+ trying to perform a modulus.
+
### ENHANCEMENTS:
- Use openssl's `-verify_hostname` option in the rsync-ssl script.
diff --git a/progress.c b/progress.c
index 8da52862..6e39ce99 100644
--- a/progress.c
+++ b/progress.c
@@ -118,10 +118,10 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now, int is_l
if (remain < 0)
strlcpy(rembuf, " ??:??:??", sizeof rembuf);
else {
- snprintf(rembuf, sizeof rembuf, "%4d:%02d:%02d",
- (int) (remain / 3600.0),
- (int) (remain / 60.0) % 60,
- (int) remain % 60);
+ snprintf(rembuf, sizeof rembuf, "%4lu:%02u:%02u",
+ (unsigned long) (remain / 3600.0),
+ (unsigned int) (remain / 60.0) % 60,
+ (unsigned int) remain % 60);
}
output_needs_newline = 0;