Fix unlikely problems with time overflow

Also, fix some rounding errors while we’re in the neighborhood.
* src/buffer.c (duration_ns, compute_duration_ns): Rename from
‘duration’ and ‘compute_duration’, and count ns rather than s, to
lessen rounding error.  All uses changed.
(compute_duration_ns): Work even if the clock moves backward
and time_t is unsigned.
(print_stats): Don’t worry about null or empty TEXT, as that
cannot happen.  Compare double to UINTMAX_MAX + 1.0, not
to UINTMAX_MAX, so that the comparison is exact.
Handle the unlikely case that numbytes >= UINTMAX_MAX.
* src/tar.c (parse_opt): Treat -L hugenumber as effectively
infinity rather than erroring out.
Prefer ckd_add to checking overflow by hand.
This commit is contained in:
Paul Eggert
2024-08-01 10:02:06 -07:00
parent aae99e863d
commit 6c91bd82e1
4 changed files with 60 additions and 36 deletions

View File

@@ -455,7 +455,7 @@ size_t available_space_after (union block *pointer);
off_t current_block_ordinal (void);
void close_archive (void);
void closeout_volume_number (void);
double compute_duration (void);
double compute_duration_ns (void);
union block *find_next_block (void);
void flush_read (void);
void flush_write (void);