2025-11-01 Paul Eggert <eggert@cs.ucla.edu>
+ nstrftime: do not return PTRDIFF_MAX
+ Previously, nstrftime (NULL, SIZE_MAX, ...) could return
+ PTRDIFF_MAX, which would cause problems in the common case
+ where the caller adds 1 to the result in order to allocate.
+ To avoid this, arrange for nstrftime to return at most PTRDIFF_MAX - 1.
+ * lib/strftime.c (__strftime_internal) [FAILURE && !FPRINTFTIME]:
+ Silently ceiling MAXSIZE to PTRDIFF_MAX.
+
nstrftime: fix very-unlikely integer overflow issues
* lib/strftime.c (SBYTE_COUNT_MAX): Remove.
(incr_overflow): New macro.
If unsuccessful, possibly change the array __S, set errno, and return -1;
errno == ERANGE means the string didn't fit.
+ As a glibc extension if __S is null, do not store anything, and
+ return the value that would have been returned had __S been non-null.
+
+ A __MAXSIZE greater than PTRDIFF_MAX is silently treated as if
+ it were PTRDIFF_MAX, so that the caller can safely add 1 to
+ any return value without overflow.
+
This function is like strftime, but with two more arguments:
* __TZ instead of the local timezone information,
* __NS as the number of nanoseconds in the %N directive,