From a32da62aa7b97467d36b67bb7f5747d32d55f294 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 20 Dec 2025 23:46:04 -0800 Subject: [PATCH] spdxtool: util: clean up strftime buffer usage Signed-off-by: Ariadne Conill --- cli/spdxtool/util.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/cli/spdxtool/util.c b/cli/spdxtool/util.c index a0d0e8a..687782a 100644 --- a/cli/spdxtool/util.c +++ b/cli/spdxtool/util.c @@ -199,25 +199,15 @@ spdxtool_util_get_spdx_id_string(pkgconf_client_t *client, char *part, char *str char * spdxtool_util_get_iso8601_time(time_t *wanted_time) { - char *buf = NULL; + char buf[PKGCONF_ITEM_SIZE]; struct tm *tm_info = gmtime(wanted_time); if(!wanted_time) - { return NULL; - } - buf = calloc(1, 21); - - if(!buf) - { - pkgconf_error(NULL, "Memory exhausted! Can't create ISO8601 time."); - return NULL; - } - - /* ISO8061 time with Z at the end */ - strftime(buf, 21, "%Y-%m-%dT%H:%M:%SZ", tm_info); - return buf; + /* ISO8601 time with Z at the end */ + strftime(buf, sizeof buf, "%Y-%m-%dT%H:%M:%SZ", tm_info); + return strdup(buf); } /*