From: Zbigniew Jędrzejewski-Szmek Date: Mon, 5 Jul 2021 19:29:11 +0000 (+0200) Subject: shared/format-table: allocate buffer of sufficient size X-Git-Tag: v250-rc1~952^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dc57047ff0f1f9e98938ffb172dae06e6868b94;p=thirdparty%2Fsystemd.git shared/format-table: allocate buffer of sufficient size --- diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 1c28fa73fa7..40996122bd8 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1441,7 +1441,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas _cleanup_free_ char *p = NULL; char *ret; - p = new(char, FORMAT_TIMESTAMP_MAX); + p = new(char, d->type == TABLE_TIMESTAMP_RELATIVE ? FORMAT_TIMESTAMP_RELATIVE_MAX : FORMAT_TIMESTAMP_MAX); if (!p) return NULL; @@ -1450,7 +1450,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas else if (d->type == TABLE_TIMESTAMP_UTC) ret = format_timestamp_style(p, FORMAT_TIMESTAMP_MAX, d->timestamp, TIMESTAMP_UTC); else - ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_MAX, d->timestamp); + ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_RELATIVE_MAX, d->timestamp); if (!ret) return "n/a";