[PATCH 4/4] pam_lastlog: Fix potential segfault when terminal_line is NULL.

Robin Hack rhack at redhat.com
Wed Aug 13 12:27:48 UTC 2014


---
 modules/pam_lastlog/pam_lastlog.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c
index 50d33e4..1bd6d65 100644
--- a/modules/pam_lastlog/pam_lastlog.c
+++ b/modules/pam_lastlog/pam_lastlog.c
@@ -176,12 +176,16 @@ get_tty(pam_handle_t *pamh)
     if (pam_get_item(pamh, PAM_TTY, &void_terminal_line) != PAM_SUCCESS
 	|| void_terminal_line == NULL) {
 	terminal_line = DEFAULT_TERM;
+    D(("terminal = %s", terminal_line));
+    return terminal_line;
     } else {
 	terminal_line = void_terminal_line;
+    D(("terminal = %s", terminal_line));
+    return terminal_line;
     }
     if (!strncmp("/dev/", terminal_line, 5)) {
-	/* strip leading "/dev/" from tty. */
-	terminal_line += 5;
+    /* strip leading "/dev/" from tty. */
+    terminal_line += 5;
     }
     D(("terminal = %s", terminal_line));
     return terminal_line;
-- 
1.9.3




More information about the Pam-list mailing list