dcavalca / rpms / util-linux

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