bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] Fix off-by-one error.


From: Martin Simmons
Subject: Re: [PATCH 2/2] Fix off-by-one error.
Date: Tue, 05 Nov 2024 09:55:41 +0000

>>>>> On Mon, 04 Nov 2024 18:13:38 -0800, Collin Funk said:
> 
> Patch 2 fixes an off-by-one error that can be seen with address
> sanitizer.

> diff --git a/src/common.h b/src/common.h
> index df87478c..c5df79f6 100644
> --- a/src/common.h
> +++ b/src/common.h
> @@ -699,7 +699,7 @@ char *timetostr (time_t, char buf[SYSINT_BUFSIZE]);
>  void code_ns_fraction (int ns, char *p);
>  enum { BILLION = 1000000000, LOG10_BILLION = 9 };
>  enum { TIMESPEC_STRSIZE_BOUND =
> -         SYSINT_BUFSIZE + LOG10_BILLION + sizeof "." - 1 };
> +         SYSINT_BUFSIZE + LOG10_BILLION + sizeof "." };
>  char const *code_timespec (struct timespec ts,
>                          char tsbuf[TIMESPEC_STRSIZE_BOUND]);
>  struct timespec decode_timespec (char const *, char **, bool);

There is also some confusion with the names of INTMAX_STRSIZE_BOUND,
UINTMAX_STRSIZE_BOUND and TIMESPEC_STRSIZE_BOUND, which seem to be based
on the naming convention from gnu/intprops.h.

INTMAX_STRSIZE_BOUND should be named INTMAX_BUFSIZE_BOUND according to
its definition and uses.  Similarly for UINTMAX_STRSIZE_BOUND.

TIMESPEC_STRSIZE_BOUND should be named TIMESPEC_BUFSIZE_BOUND according
to its uses (and your new definition).

__Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]