]> err.no Git - util-linux/commitdiff
login: login segfaults on EOF (rh#298461)
authorKarel Zak <kzak@redhat.com>
Thu, 20 Sep 2007 22:34:30 +0000 (00:34 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 20 Sep 2007 22:34:30 +0000 (00:34 +0200)
Stupid bug in audit code:

  $ login
  login: ^D
  login: ^D
  Segmentation fault

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index e582779efddf1046a01599d4a4f9638401dd2eae..1af87925a81b4ae61215702cf1f52c2f18a69859 100644 (file)
@@ -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);