Song, Jiaying (CN) via Postfix-devel:
> From: Jiaying Song <[email protected]>
>
> This patch replaces "%010ld" with "%019" PRIdMAX and casts time() to
> intmax_t, to prevent formatting overflow on systems where long is 32-bit
> but time_t is 64-bit.
>
> The previous formatting could truncate high-bit time values, causing
> unexpected behavior in mail queue operations on systems with time beyond
> 2038.
>
> This ensures safe formatting of time values across 32-bit and 64-bit
> systems.
>
> Signed-off-by: Jiaying Song <[email protected]>
> ---
> postfix/src/postalias/postalias.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/postfix/src/postalias/postalias.c
> b/postfix/src/postalias/postalias.c
> index 9e77a6b20..ebb1dc329 100644
> --- a/postfix/src/postalias/postalias.c
> +++ b/postfix/src/postalias/postalias.c
> @@ -489,7 +489,7 @@ static void postalias(char *map_type, char *path_name,
> int postalias_flags,
> */
> mkmap->dict->flags &= ~DICT_FLAG_TRY1NULL;
> mkmap->dict->flags |= DICT_FLAG_TRY0NULL;
> - vstring_sprintf(value_buffer, "%010ld", (long) time((time_t *) 0));
> + vstring_sprintf(value_buffer, "%019" PRIdMAX, (intmax_t)time(NULL));
> #if (defined(HAS_NIS) || defined(HAS_NISPLUS))
> mkmap->dict->flags &= ~DICT_FLAG_FOLD_FIX;
> mkmap_append(mkmap, "YP_LAST_MODIFIED", STR(value_buffer));
How did you test this patch?
1) On the systems that I have, PRIdMAX is one of 'lld', 'ld' or
'jd'. At this time, the Postfix vstring_sprintf() implementation
does not yet support the 'lld' or 'jd' formats.
2) What NIS implementation was your patch tested with?
3) Changing the %010ld" format seems unnecessary. It specifies the
MINIMUM number of digits to print, NOT a maximum.
Wietse
Wietse
_______________________________________________
Postfix-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]