c22a38
diff -up Linux-PAM-1.1.7/modules/pam_tty_audit/pam_tty_audit.c.tty-audit-init Linux-PAM-1.1.7/modules/pam_tty_audit/pam_tty_audit.c
c22a38
--- Linux-PAM-1.1.7/modules/pam_tty_audit/pam_tty_audit.c.tty-audit-init	2013-08-28 10:53:40.000000000 +0200
c22a38
+++ Linux-PAM-1.1.7/modules/pam_tty_audit/pam_tty_audit.c	2013-10-04 14:51:19.944994905 +0200
c22a38
@@ -36,6 +36,7 @@
c22a38
    USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
c22a38
    DAMAGE. */
c22a38
 
c22a38
+#include "config.h"
c22a38
 #include <errno.h>
c22a38
 #include <fnmatch.h>
c22a38
 #include <stdlib.h>
c22a38
@@ -108,7 +109,7 @@ nl_recv (int fd, unsigned type, void *bu
c22a38
   struct msghdr msg;
c22a38
   struct nlmsghdr nlm;
c22a38
   struct iovec iov[2];
c22a38
-  ssize_t res;
c22a38
+  ssize_t res, resdiff;
c22a38
 
c22a38
  again:
c22a38
   iov[0].iov_base = &nlm;
c22a38
@@ -160,12 +161,17 @@ nl_recv (int fd, unsigned type, void *bu
c22a38
   res = recvmsg (fd, &msg, 0);
c22a38
   if (res == -1)
c22a38
     return -1;
c22a38
-  if ((size_t)res != NLMSG_LENGTH (size)
c22a38
+  resdiff = NLMSG_LENGTH(size) - (size_t)res;
c22a38
+  if (resdiff < 0
c22a38
       || nlm.nlmsg_type != type)
c22a38
     {
c22a38
       errno = EIO;
c22a38
       return -1;
c22a38
     }
c22a38
+  else if (resdiff > 0)
c22a38
+    {
c22a38
+      memset((char *)buf + size - resdiff, 0, resdiff);
c22a38
+    }
c22a38
   return 0;
c22a38
 }
c22a38
 
c22a38
@@ -275,6 +281,8 @@ pam_sm_open_session (pam_handle_t *pamh,
c22a38
       return PAM_SESSION_ERR;
c22a38
     }
c22a38
 
c22a38
+  memcpy(&new_status, old_status, sizeof(new_status));
c22a38
+
c22a38
   new_status.enabled = (command == CMD_ENABLE ? 1 : 0);
c22a38
 #ifdef HAVE_STRUCT_AUDIT_TTY_STATUS_LOG_PASSWD
c22a38
   new_status.log_passwd = log_passwd;