From e797d83232802cf439b2ed893e784d3636357349 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 21 Sep 2007 00:34:30 +0200 Subject: [PATCH] login: login segfaults on EOF (rh#298461) Stupid bug in audit code: $ login login: ^D login: ^D Segmentation fault Signed-off-by: Karel Zak --- login-utils/login.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/login-utils/login.c b/login-utils/login.c index e582779e..1af87925 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -330,12 +330,12 @@ logaudit(const char *tty, const char *username, const char *hostname, audit_fd = audit_open(); if (audit_fd == -1) return; - if (!pwd) + if (!pwd && username) pwd = getpwnam(username); if (pwd) snprintf(buf, sizeof(buf), "uid=%d", pwd->pw_uid); else - snprintf(buf, sizeof(buf), "acct=%s", username); + snprintf(buf, sizeof(buf), "acct=%s", username ? username : "(unknown)"); audit_log_user_message(audit_fd, AUDIT_USER_LOGIN, buf, hostname, NULL, tty, status); -- 2.39.5