]> granicus.if.org Git - linux-pam/commitdiff
pam_lastlog: Properly clean up last_login structure before use.
authorTomas Mraz <tmraz@fedoraproject.org>
Tue, 5 Aug 2014 14:26:01 +0000 (16:26 +0200)
committerTomas Mraz <tmraz@fedoraproject.org>
Tue, 5 Aug 2014 14:26:01 +0000 (16:26 +0200)
modules/pam_lastlog/pam_lastlog.c (last_login_write): Properly clean up last_login
structure before use.

modules/pam_lastlog/pam_lastlog.c

index ad8c66053cc75f83f4bb06f4f32798a7048bcebf..50d33e40af63b60550dcb604b23733044f3db06f 100644 (file)
@@ -350,6 +350,8 @@ last_login_write(pam_handle_t *pamh, int announce, int last_fd,
        return PAM_SERVICE_ERR;
     }
 
+    memset(&last_login, 0, sizeof(last_login));
+
     /* set this login date */
     D(("set the most recent login time"));
     (void) time(&ll_time);    /* set the time */
@@ -364,14 +366,12 @@ last_login_write(pam_handle_t *pamh, int announce, int last_fd,
     }
 
     /* copy to last_login */
-    last_login.ll_host[0] = '\0';
     strncat(last_login.ll_host, remote_host, sizeof(last_login.ll_host)-1);
 
     /* set the terminal line */
     terminal_line = get_tty(pamh);
 
     /* copy to last_login */
-    last_login.ll_line[0] = '\0';
     strncat(last_login.ll_line, terminal_line, sizeof(last_login.ll_line)-1);
     terminal_line = NULL;