From 46e013988f70e194a0ed0cd9933a5b4f882223b2 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 25 Mar 2024 13:20:54 +0100 Subject: [PATCH] cov: check for strftime result --- lib/device/dev-cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 789d8487f..d97a90828 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -1846,7 +1846,9 @@ static void devices_file_rename_unused(struct cmd_context *cmd) t = time(NULL); if (!(tm = localtime(&t))) return; - strftime(datetime_str, sizeof(datetime_str), "%Y%m%d.%H%M%S", tm); + + if (!strftime(datetime_str, sizeof(datetime_str), "%Y%m%d.%H%M%S", tm)) + return; if (dm_snprintf(path2, sizeof(path2), "%s/devices/%s-unused.%s", cmd->system_dir, filename, datetime_str) < 0) return;