673c78
From 1c4ee8348e220b633d676214fd585ee2b3945cf6 Mon Sep 17 00:00:00 2001
673c78
From: Karel Zak <kzak@redhat.com>
673c78
Date: Mon, 6 Jun 2022 16:14:14 +0200
673c78
Subject: login-utils/logindefs: fix compiler warning
673c78
 [-Werror=format-truncation=]
673c78
673c78
Upstream: http://github.com/util-linux/util-linux/commit/977f98ee34ca002cb5301c2d3a5953c754f813ec
673c78
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
673c78
Signed-off-by: Karel Zak <kzak@redhat.com>
673c78
---
673c78
 login-utils/logindefs.c | 3 ++-
673c78
 1 file changed, 2 insertions(+), 1 deletion(-)
673c78
673c78
diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c
673c78
index 97150dc28..95631223a 100644
673c78
--- a/login-utils/logindefs.c
673c78
+++ b/login-utils/logindefs.c
673c78
@@ -521,7 +521,8 @@ int get_hushlogin_status(struct passwd *pwd, int force_check)
673c78
 		if (strlen(pwd->pw_dir) + strlen(file) + 2 > sizeof(buf))
673c78
 			continue;
673c78
 
673c78
-		sprintf(buf, "%s/%s", pwd->pw_dir, file);
673c78
+		if (snprintf(buf, sizeof(buf), "%s/%s", pwd->pw_dir, file) < 0)
673c78
+			continue;
673c78
 
673c78
 		if (force_check) {
673c78
 			uid_t ruid = getuid();
673c78
-- 
673c78
2.36.1
673c78