Download raw body.
Am 25.09.2025 um 11:35 schrieb Marc Espie:
> cc now warns over arch.c
> /usr/src/usr.bin/make/arch.c:839:3: warning: 'snprintf' will always be truncated; specified size is 12, but format string expands to at least 13 [-Wformat-truncation]
> 839 | snprintf(arHeader.ar_date, sizeof(arHeader.ar_date),
> | ^
>
>
> Pretty sure it's correct, considering that snprintf will truncate with a 0.
>
> Printing to a temp buffer and copying only the string ought to fix it
> if I'm not mistaken.
>
> Index: arch.c
> ===================================================================
> RCS file: /vide/cvs/src/usr.bin/make/arch.c,v
> diff -u -p -r1.94 arch.c
> --- arch.c 4 Sep 2023 11:35:11 -0000 1.94
> +++ arch.c 25 Sep 2025 09:33:07 -0000
> @@ -836,8 +836,9 @@ ArchTouch(const char *archive, const cha
>
> arch = ArchFindMember(archive, member, &arHeader, "r+");
> if (arch != NULL) {
> - snprintf(arHeader.ar_date, sizeof(arHeader.ar_date),
> - "%-12ld", (long) time(NULL));
> + char temp[sizeof(arHeader.ar_date)+1];
> + snprintf(temp, sizeof(temp), "%-12ld", (long) time(NULL));
I am really not sure but I think this should read "%-12" PRIdMAX,
(intmax_t)time(NULL));
Just my 2 cents.
--
Christian