87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.old	2016-01-22 16:27:56.867903172 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c	2016-01-22 16:56:48.114868014 +0100
87ab5fc
@@ -59,6 +59,8 @@
87ab5fc
 #include "get_command_line.h"
87ab5fc
 extern char **environ;
87ab5fc
 
87ab5fc
+#define PAM_SSH_AGENT_AUTH_REQUESTv1 101
87ab5fc
+
87ab5fc
 /* 
87ab5fc
  * Added by Jamie Beverly, ensure socket fd points to a socket owned by the user 
87ab5fc
  * A cursory check is done, but to avoid race conditions, it is necessary 
87ab5fc
@@ -77,7 +77,7 @@ log_action(char ** action, size_t count)
87ab5fc
     if (count == 0)
87ab5fc
         return NULL;
87ab5fc
    
87ab5fc
-    buf = pamsshagentauth_xcalloc((count * MAX_LEN_PER_CMDLINE_ARG) + (count * 3), sizeof(*buf));
87ab5fc
+    buf = xcalloc((count * MAX_LEN_PER_CMDLINE_ARG) + (count * 3), sizeof(*buf));
87ab5fc
     for (i = 0; i < count; i++) {
87ab5fc
         strcat(buf, (i > 0) ? " '" : "'");
87ab5fc
         strncat(buf, action[i], MAX_LEN_PER_CMDLINE_ARG);
87ab5fc
@@ -71,12 +90,12 @@ void
87ab5fc
 agent_action(Buffer *buf, char ** action, size_t count)
87ab5fc
 {
87ab5fc
     size_t i;
87ab5fc
-    pamsshagentauth_buffer_init(buf);
87ab5fc
+    buffer_init(buf);
87ab5fc
 
87ab5fc
-    pamsshagentauth_buffer_put_int(buf, count);
87ab5fc
+    buffer_put_int(buf, count);
87ab5fc
 
87ab5fc
     for (i = 0; i < count; i++) {
87ab5fc
-        pamsshagentauth_buffer_put_cstring(buf, action[i]);
87ab5fc
+        buffer_put_cstring(buf, action[i]);
87ab5fc
     }
87ab5fc
 }
87ab5fc
 
87ab5fc
@@ -100,7 +119,7 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5fc
     char * retc;
87ab5fc
     int32_t reti;
87ab5fc
 
87ab5fc
-    rnd = pamsshagentauth_arc4random();
87ab5fc
+    rnd = arc4random();
87ab5fc
     cookie_len = ((uint8_t) rnd);
87ab5fc
     while (cookie_len < 16) { 
87ab5fc
         cookie_len += 16;                                          /* Add 16 bytes to the size to ensure that while the length is random, the length is always reasonable; ticket #18 */
87ab5fc
@@ -126,7 +128,7 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5fc
         cookie_len += 16;                                          /* Add 16 bytes to the size to ensure that while the length is random, the length is always reasonable; ticket #18 */
87ab5fc
     }
87ab5fc
 
87ab5fc
-    cookie = pamsshagentauth_xcalloc(1,cookie_len);
87ab5fc
+    cookie = xcalloc(1,cookie_len);
87ab5fc
 
87ab5fc
     for (i = 0; i < cookie_len; i++) {
87ab5fc
         if (i % 4 == 0) {
87ab5fc
@@ -110,7 +129,7 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5fc
 
87ab5fc
     for (i = 0; i < cookie_len; i++) {
87ab5fc
         if (i % 4 == 0) {
87ab5fc
-            rnd = pamsshagentauth_arc4random();
87ab5fc
+            rnd = arc4random();
87ab5fc
         }
87ab5fc
         cookie[i] = (u_char) rnd;
87ab5fc
         rnd >>= 8;
87ab5fc
@@ -125,7 +144,7 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5fc
     }
87ab5fc
     else {
87ab5fc
         action_logbuf = "unknown on this platform";
87ab5fc
-        pamsshagentauth_buffer_init(&action_agentbuf); /* stays empty, means unavailable */
87ab5fc
+        buffer_init(&action_agentbuf); /* stays empty, means unavailable */
87ab5fc
     }
87ab5fc
     
87ab5fc
     /*
87ab5fc
@@ -142,35 +161,35 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5fc
     retc = getcwd(pwd, sizeof(pwd) - 1);
87ab5fc
     time(&ts);
87ab5fc
 
87ab5fc
-    pamsshagentauth_buffer_init(session_id2);
87ab5fc
+    buffer_init(session_id2);
87ab5fc
 
87ab5fc
-    pamsshagentauth_buffer_put_int(session_id2, PAM_SSH_AGENT_AUTH_REQUESTv1);
87ab5fc
-    /* pamsshagentauth_debug3("cookie: %s", pamsshagentauth_tohex(cookie, cookie_len)); */
87ab5fc
-    pamsshagentauth_buffer_put_string(session_id2, cookie, cookie_len);
87ab5fc
-    /* pamsshagentauth_debug3("user: %s", user); */
87ab5fc
-    pamsshagentauth_buffer_put_cstring(session_id2, user);
87ab5fc
-    /* pamsshagentauth_debug3("ruser: %s", ruser); */
87ab5fc
-    pamsshagentauth_buffer_put_cstring(session_id2, ruser);
87ab5fc
-    /* pamsshagentauth_debug3("servicename: %s", servicename); */
87ab5fc
-    pamsshagentauth_buffer_put_cstring(session_id2, servicename);
87ab5fc
-    /* pamsshagentauth_debug3("pwd: %s", pwd); */
87ab5fc
+    buffer_put_int(session_id2, PAM_SSH_AGENT_AUTH_REQUESTv1);
87ab5fc
+    /* debug3("cookie: %s", tohex(cookie, cookie_len)); */
87ab5fc
+    buffer_put_string(session_id2, cookie, cookie_len);
87ab5fc
+    /* debug3("user: %s", user); */
87ab5fc
+    buffer_put_cstring(session_id2, user);
87ab5fc
+    /* debug3("ruser: %s", ruser); */
87ab5fc
+    buffer_put_cstring(session_id2, ruser);
87ab5fc
+    /* debug3("servicename: %s", servicename); */
87ab5fc
+    buffer_put_cstring(session_id2, servicename);
87ab5fc
+    /* debug3("pwd: %s", pwd); */
87ab5fc
     if(retc)
87ab5fc
-        pamsshagentauth_buffer_put_cstring(session_id2, pwd);
87ab5fc
+        buffer_put_cstring(session_id2, pwd);
87ab5fc
     else
87ab5fc
-        pamsshagentauth_buffer_put_cstring(session_id2, "");
87ab5fc
-    /* pamsshagentauth_debug3("action: %s", action_logbuf); */
87ab5fc
-    pamsshagentauth_buffer_put_string(session_id2, action_agentbuf.buf + action_agentbuf.offset, action_agentbuf.end - action_agentbuf.offset);
87ab5fc
+        buffer_put_cstring(session_id2, "");
87ab5fc
+    /* debug3("action: %s", action_logbuf); */
87ab5fc
+    buffer_put_string(session_id2, sshbuf_ptr(&action_agentbuf), sshbuf_len(&action_agentbuf));
87ab5fc
     if (free_logbuf) { 
87ab5fc
-        pamsshagentauth_xfree(action_logbuf);
87ab5fc
-        pamsshagentauth_buffer_free(&action_agentbuf);
87ab5fc
+        free(action_logbuf);
87ab5fc
+        buffer_free(&action_agentbuf);
87ab5fc
     }
87ab5fc
-    /* pamsshagentauth_debug3("hostname: %s", hostname); */
87ab5fc
+    /* debug3("hostname: %s", hostname); */
87ab5fc
     if(reti >= 0)
87ab5fc
-        pamsshagentauth_buffer_put_cstring(session_id2, hostname);
87ab5fc
+        buffer_put_cstring(session_id2, hostname);
87ab5fc
     else
87ab5fc
-        pamsshagentauth_buffer_put_cstring(session_id2, "");
87ab5fc
-    /* pamsshagentauth_debug3("ts: %ld", ts); */
87ab5fc
-    pamsshagentauth_buffer_put_int64(session_id2, (uint64_t) ts);
87ab5fc
+        buffer_put_cstring(session_id2, "");
87ab5fc
+    /* debug3("ts: %ld", ts); */
87ab5fc
+    buffer_put_int64(session_id2, (uint64_t) ts);
87ab5fc
 
87ab5fc
     free(cookie);
87ab5fc
     return;
87ab5fc
@@ -190,11 +289,11 @@ pamsshagentauth_find_authorized_keys(con
87ab5fc
     pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
87ab5fc
 
87ab5fc
     if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
87ab5fc
-        pamsshagentauth_verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
87ab5fc
+        verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
87ab5fc
         for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2)) 
87ab5fc
         {
87ab5fc
             if(key != NULL) {
87ab5fc
-                id = pamsshagentauth_xcalloc(1, sizeof(*id));
87ab5fc
+                id = xcalloc(1, sizeof(*id));
87ab5fc
                 id->key = key;
87ab5fc
                 id->filename = comment;
87ab5fc
                 id->ac = ac;
87ab5fc
@@ -203,18 +302,18 @@ pamsshagentauth_find_authorized_keys(con
87ab5fc
                 if(userauth_pubkey_from_id(ruser, id, &session_id2)) {
87ab5fc
                     retval = 1;
87ab5fc
                 }
87ab5fc
-                pamsshagentauth_xfree(id->filename);
87ab5fc
-                pamsshagentauth_key_free(id->key);
87ab5fc
-                pamsshagentauth_xfree(id);
87ab5fc
+                free(id->filename);
87ab5fc
+                key_free(id->key);
87ab5fc
+                free(id);
87ab5fc
                 if(retval == 1)
87ab5fc
                     break;
87ab5fc
             }
87ab5fc
         }
87ab5fc
-        pamsshagentauth_buffer_free(&session_id2);
87ab5fc
+        buffer_free(&session_id2);
87ab5fc
         ssh_close_authentication_connection(ac);
87ab5fc
     }
87ab5fc
     else {
87ab5fc
-        pamsshagentauth_verbose("No ssh-agent could be contacted");
87ab5fc
+        verbose("No ssh-agent could be contacted");
87ab5fc
     }
87ab5fc
     /* pamsshagentauth_xfree(session_id2); */
87ab5fc
     EVP_cleanup();
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c.old	2016-01-22 17:03:42.746602825 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c	2016-01-22 17:06:07.841485483 +0100
87ab5fc
@@ -104,7 +104,7 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
  * a patch 8-)
87ab5fc
  */
87ab5fc
 #if ! HAVE___PROGNAME || HAVE_BUNDLE
87ab5fc
-    __progname = pamsshagentauth_xstrdup(servicename);
87ab5fc
+    __progname = xstrdup(servicename);
87ab5fc
 #endif
87ab5fc
 
87ab5fc
     for(i = argc, argv_ptr = (char **) argv; i > 0; ++argv_ptr, i--) {
87ab5fc
@@ -130,11 +130,11 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
 #endif
87ab5fc
     }
87ab5fc
 
87ab5fc
-    pamsshagentauth_log_init(__progname, log_lvl, facility, 0);
87ab5fc
+    log_init(__progname, log_lvl, facility, 0);
87ab5fc
     pam_get_item(pamh, PAM_USER, (void *) &user);
87ab5fc
     pam_get_item(pamh, PAM_RUSER, (void *) &ruser_ptr);
87ab5fc
 
87ab5fc
-    pamsshagentauth_verbose("Beginning pam_ssh_agent_auth for user %s", user);
87ab5fc
+    verbose("Beginning pam_ssh_agent_auth for user %s", user);
87ab5fc
 
87ab5fc
     if(ruser_ptr) {
87ab5fc
         strncpy(ruser, ruser_ptr, sizeof(ruser) - 1);
87ab5fc
@@ -149,12 +149,12 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
 #ifdef ENABLE_SUDO_HACK
87ab5fc
         if( (strlen(sudo_service_name) > 0) && strncasecmp(servicename, sudo_service_name, sizeof(sudo_service_name) - 1) == 0 && getenv("SUDO_USER") ) {
87ab5fc
             strncpy(ruser, getenv("SUDO_USER"), sizeof(ruser) - 1 );
87ab5fc
-            pamsshagentauth_verbose( "Using environment variable SUDO_USER (%s)", ruser );
87ab5fc
+            verbose( "Using environment variable SUDO_USER (%s)", ruser );
87ab5fc
         } else 
87ab5fc
 #endif
87ab5fc
         {
87ab5fc
             if( ! getpwuid(getuid()) ) {
87ab5fc
-                pamsshagentauth_verbose("Unable to getpwuid(getuid())");
87ab5fc
+                verbose("Unable to getpwuid(getuid())");
87ab5fc
                 goto cleanexit;
87ab5fc
             }
87ab5fc
             strncpy(ruser, getpwuid(getuid())->pw_name, sizeof(ruser) - 1);
87ab5fc
@@ -163,11 +163,11 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
 
87ab5fc
     /* Might as well explicitely confirm the user exists here */
87ab5fc
     if(! getpwnam(ruser) ) {
87ab5fc
-        pamsshagentauth_verbose("getpwnam(%s) failed, bailing out", ruser);
87ab5fc
+        verbose("getpwnam(%s) failed, bailing out", ruser);
87ab5fc
         goto cleanexit;
87ab5fc
     }
87ab5fc
     if( ! getpwnam(user) ) {
87ab5fc
-        pamsshagentauth_verbose("getpwnam(%s) failed, bailing out", user);
87ab5fc
+        verbose("getpwnam(%s) failed, bailing out", user);
87ab5fc
         goto cleanexit;
87ab5fc
     }
87ab5fc
 
87ab5fc
@@ -177,8 +177,8 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
          */
87ab5fc
         parse_authorized_key_file(user, authorized_keys_file_input);
87ab5fc
     } else {
87ab5fc
-        pamsshagentauth_verbose("Using default file=/etc/security/authorized_keys");
87ab5fc
-        authorized_keys_file = pamsshagentauth_xstrdup("/etc/security/authorized_keys");
87ab5fc
+        verbose("Using default file=/etc/security/authorized_keys");
87ab5fc
+        authorized_keys_file = xstrdup("/etc/security/authorized_keys");
87ab5fc
     }
87ab5fc
 
87ab5fc
     /* 
87ab5fc
@@ -187,19 +187,19 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5fc
      */
87ab5fc
 
87ab5fc
     if(user && strlen(ruser) > 0) {
87ab5fc
-        pamsshagentauth_verbose("Attempting authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
+        verbose("Attempting authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
 
87ab5fc
         /* 
87ab5fc
          * this pw_uid is used to validate the SSH_AUTH_SOCK, and so must be the uid of the ruser invoking the program, not the target-user
87ab5fc
          */
87ab5fc
         if(pamsshagentauth_find_authorized_keys(user, ruser, servicename)) { /* getpwnam(ruser)->pw_uid)) { */
87ab5fc
-            pamsshagentauth_logit("Authenticated: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
+            logit("Authenticated: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
             retval = PAM_SUCCESS;
87ab5fc
         } else {
87ab5fc
-            pamsshagentauth_logit("Failed Authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
+            logit("Failed Authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5fc
         }
87ab5fc
     } else {
87ab5fc
-        pamsshagentauth_logit("No %s specified, cannot continue with this form of authentication", (user) ? "ruser" : "user" );
87ab5fc
+        logit("No %s specified, cannot continue with this form of authentication", (user) ? "ruser" : "user" );
87ab5fc
     }
87ab5fc
 
87ab5fc
 cleanexit:
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.old	2016-01-22 16:57:15.210850825 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c	2016-01-22 17:03:13.913623276 +0100
87ab5fc
@@ -48,6 +48,8 @@
87ab5fc
 #include "identity.h"
87ab5fc
 #include "pam_user_authorized_keys.h"
87ab5fc
 
87ab5fc
+#define SSH2_MSG_USERAUTH_TRUST_REQUEST          54
87ab5fc
+
87ab5fc
 /* extern u_char  *session_id2;
87ab5fc
 extern uint8_t  session_id_len;
87ab5fc
  */
87ab5fc
@@ -67,35 +67,35 @@ userauth_pubkey_from_id(const char *ruse
87ab5fc
     if(! pam_user_key_allowed(ruser, id->key))
87ab5fc
         goto user_auth_clean_exit;
87ab5fc
 
87ab5fc
-    if(pamsshagentauth_key_to_blob(id->key, &pkblob, &blen) == 0)
87ab5fc
+    if(key_to_blob(id->key, &pkblob, &blen) == 0)
87ab5fc
         goto user_auth_clean_exit;
87ab5fc
 
87ab5fc
     /* construct packet to sign and test */
87ab5fc
-    pamsshagentauth_buffer_init(&b);
87ab5fc
+    buffer_init(&b);
87ab5fc
 
87ab5fc
-    pamsshagentauth_buffer_put_string(&b, session_id2->buf + session_id2->offset, session_id2->end - session_id2->offset);
87ab5fc
-    pamsshagentauth_buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST); 
87ab5fc
-    pamsshagentauth_buffer_put_cstring(&b, ruser);
87ab5fc
-    pamsshagentauth_buffer_put_cstring(&b, "pam_ssh_agent_auth");
87ab5fc
-    pamsshagentauth_buffer_put_cstring(&b, "publickey");
87ab5fc
-    pamsshagentauth_buffer_put_char(&b, 1);
87ab5fc
-    pamsshagentauth_buffer_put_cstring(&b, pkalg);
87ab5fc
-    pamsshagentauth_buffer_put_string(&b, pkblob, blen);
87ab5fc
+    buffer_put_string(&b, sshbuf_ptr(session_id2), sshbuf_len(session_id2));
87ab5fc
+    buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST); 
87ab5fc
+    buffer_put_cstring(&b, ruser);
87ab5fc
+    buffer_put_cstring(&b, "pam_ssh_agent_auth");
87ab5fc
+    buffer_put_cstring(&b, "publickey");
87ab5fc
+    buffer_put_char(&b, 1);
87ab5fc
+    buffer_put_cstring(&b, pkalg);
87ab5fc
+    buffer_put_string(&b, pkblob, blen);
87ab5fc
 
87ab5fc
-    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) != 0)
87ab5fc
+    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
87ab5fc
         goto user_auth_clean_exit;
87ab5fc
 
87ab5fc
     /* test for correct signature */
87ab5fc
-    if(pamsshagentauth_key_verify(id->key, sig, slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) == 1)
87ab5fc
+    if(key_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
87ab5fc
         authenticated = 1;
87ab5fc
 
87ab5fc
   user_auth_clean_exit:
87ab5fc
     /* if(&b != NULL) */
87ab5fc
-    pamsshagentauth_buffer_free(&b);
87ab5fc
+    buffer_free(&b);
87ab5fc
     if(sig != NULL)
87ab5fc
-        pamsshagentauth_xfree(sig);
87ab5fc
+        free(sig);
87ab5fc
     if(pkblob != NULL)
87ab5fc
-        pamsshagentauth_xfree(pkblob);
87ab5fc
+        free(pkblob);
87ab5fc
     CRYPTO_cleanup_all_ex_data();
87ab5fc
     return authenticated;
87ab5fc
 }
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c.old	2016-01-22 17:12:03.026198234 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c	2016-01-22 17:12:31.817174950 +0100
87ab5fc
@@ -80,7 +80,7 @@ pamsshagentauth_auth_secure_path(const c
87ab5fc
 	int comparehome = 0;
87ab5fc
 	struct stat st;
87ab5fc
 
87ab5fc
-    pamsshagentauth_verbose("auth_secure_filename: checking for uid: %u", uid);
87ab5fc
+    verbose("auth_secure_filename: checking for uid: %u", uid);
87ab5fc
 
87ab5fc
 	if (realpath(name, buf) == NULL) {
87ab5fc
 		snprintf(err, errlen, "realpath %s failed: %s", name,
87ab5fc
@@ -115,9 +115,9 @@ pamsshagentauth_auth_secure_path(const c
87ab5fc
 			snprintf(err, errlen, "dirname() failed");
87ab5fc
 			return -1;
87ab5fc
 		}
87ab5fc
-		pamsshagentauth_strlcpy(buf, cp, sizeof(buf));
87ab5fc
+		strlcpy(buf, cp, sizeof(buf));
87ab5fc
 
87ab5fc
-		pamsshagentauth_verbose("secure_filename: checking '%s'", buf);
87ab5fc
+		verbose("secure_filename: checking '%s'", buf);
87ab5fc
 		if (stat(buf, &st) < 0 ||
87ab5fc
 		    (st.st_uid != 0 && st.st_uid != uid) ||
87ab5fc
 		    (st.st_mode & 022) != 0) {
87ab5fc
@@ -128,7 +128,7 @@ pamsshagentauth_auth_secure_path(const c
87ab5fc
 
87ab5fc
 		/* If are passed the homedir then we can stop */
87ab5fc
 		if (comparehome && strcmp(homedir, buf) == 0) {
87ab5fc
-			pamsshagentauth_verbose("secure_filename: terminating check at '%s'",
87ab5fc
+			verbose("secure_filename: terminating check at '%s'",
87ab5fc
 			    buf);
87ab5fc
 			break;
87ab5fc
 		}
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c.old	2016-01-22 17:13:18.226137418 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c	2016-01-22 17:14:27.753081189 +0100
87ab5fc
@@ -65,8 +65,8 @@ proc_pid_cmdline(char *** inargv)
87ab5fc
                 case EOF:
87ab5fc
                 case '\0':
87ab5fc
                     if (len > 0) { 
87ab5fc
-                        argv = pamsshagentauth_xrealloc(argv, count + 1, sizeof(*argv));
87ab5fc
-                        argv[count] = pamsshagentauth_xcalloc(len + 1, sizeof(*argv[count]));
87ab5fc
+                        argv = xreallocarray(argv, count + 1, sizeof(*argv));
87ab5fc
+                        argv[count] = xcalloc(len + 1, sizeof(*argv[count]));
87ab5fc
                         strncpy(argv[count++], argbuf, len);
87ab5fc
                         memset(argbuf, '\0', MAX_LEN_PER_CMDLINE_ARG + 1);
87ab5fc
                         len = 0;
87ab5fc
@@ -105,9 +105,9 @@ pamsshagentauth_free_command_line(char *
87ab5fc
 {
87ab5fc
     size_t i;
87ab5fc
     for (i = 0; i < n_args; i++)
87ab5fc
-        pamsshagentauth_xfree(argv[i]);
87ab5fc
+        free(argv[i]);
87ab5fc
 
87ab5fc
-    pamsshagentauth_xfree(argv);
87ab5fc
+    free(argv);
87ab5fc
     return;
87ab5fc
 }
87ab5fc
 
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c.old	2016-01-22 17:15:57.547008570 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c	2016-01-22 17:16:18.297991788 +0100
87ab5fc
@@ -48,6 +48,7 @@
87ab5fc
 #include "buffer.h"
87ab5fc
 #include "log.h"
87ab5fc
 #include "compat.h"
87ab5fc
+#include "digest.h"
87ab5fc
 #include "key.h"
87ab5fc
 #include "pathnames.h"
87ab5fc
 #include "misc.h"
87ab5fc
@@ -54,6 +54,7 @@
87ab5fc
 #include "misc.h"
87ab5fc
 #include "secure_filename.h"
87ab5fc
 #include "uidswap.h"
87ab5fc
+#include <unistd.h>
87ab5fc
 
87ab5fc
 #include "identity.h"
87ab5fc
 
87ab5fc
@@ -68,7 +68,7 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5fc
     char *fp;
87ab5fc
 
87ab5fc
     found_key = 0;
87ab5fc
-    found = pamsshagentauth_key_new(key->type);
87ab5fc
+    found = key_new(key->type);
87ab5fc
 
87ab5fc
     while(read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
87ab5fc
         char *cp = NULL; /* *key_options = NULL; */
87ab5fc
@@ -78,11 +78,11 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5fc
         if(!*cp || *cp == '\n' || *cp == '#')
87ab5fc
             continue;
87ab5fc
 
87ab5fc
-        if(pamsshagentauth_key_read(found, &cp) != 1) {
87ab5fc
+        if(key_read(found, &cp) != 1) {
87ab5fc
             /* no key? check if there are options for this key */
87ab5fc
             int quoted = 0;
87ab5fc
 
87ab5fc
-            pamsshagentauth_verbose("user_key_allowed: check options: '%s'", cp);
87ab5fc
+            verbose("user_key_allowed: check options: '%s'", cp);
87ab5fc
             /* key_options = cp; */
87ab5fc
             for(; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
87ab5fc
                 if(*cp == '\\' && cp[1] == '"')
87ab5fc
@@ -92,26 +92,26 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5fc
             }
87ab5fc
             /* Skip remaining whitespace. */
87ab5fc
             for(; *cp == ' ' || *cp == '\t'; cp++);
87ab5fc
-            if(pamsshagentauth_key_read(found, &cp) != 1) {
87ab5fc
-                pamsshagentauth_verbose("user_key_allowed: advance: '%s'", cp);
87ab5fc
+            if(key_read(found, &cp) != 1) {
87ab5fc
+                verbose("user_key_allowed: advance: '%s'", cp);
87ab5fc
                 /* still no key? advance to next line */
87ab5fc
                 continue;
87ab5fc
             }
87ab5fc
         }
87ab5fc
-        if(pamsshagentauth_key_equal(found, key)) {
87ab5fc
+        if(key_equal(found, key)) {
87ab5fc
             found_key = 1;
87ab5fc
-            pamsshagentauth_logit("matching key found: file/command %s, line %lu", file,
87ab5fc
+            logit("matching key found: file/command %s, line %lu", file,
87ab5fc
                                   linenum);
87ab5fc
-            fp = pamsshagentauth_key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
87ab5fc
-            pamsshagentauth_logit("Found matching %s key: %s",
87ab5fc
-                                  pamsshagentauth_key_type(found), fp);
87ab5fc
-            pamsshagentauth_xfree(fp);
87ab5fc
+            fp = sshkey_fingerprint(found, SSH_DIGEST_MD5, SSH_FP_HEX);
87ab5fc
+            logit("Found matching %s key: %s",
87ab5fc
+                                  key_type(found), fp);
87ab5fc
+            free(fp);
87ab5fc
             break;
87ab5fc
         }
87ab5fc
     }
87ab5fc
-    pamsshagentauth_key_free(found);
87ab5fc
+    key_free(found);
87ab5fc
     if(!found_key)
87ab5fc
-        pamsshagentauth_verbose("key not found");
87ab5fc
+        verbose("key not found");
87ab5fc
     return found_key;
87ab5fc
 }
87ab5fc
 
87ab5fc
@@ -128,11 +128,11 @@ pamsshagentauth_user_key_allowed2(struct
87ab5fc
     char buf[SSH_MAX_PUBKEY_BYTES];
87ab5fc
 
87ab5fc
     /* Temporarily use the user's uid. */
87ab5fc
-    pamsshagentauth_verbose("trying public key file %s", file);
87ab5fc
+    verbose("trying public key file %s", file);
87ab5fc
 
87ab5fc
     /* Fail not so quietly if file does not exist */
87ab5fc
     if(stat(file, &st) < 0) {
87ab5fc
-        pamsshagentauth_verbose("File not found: %s", file);
87ab5fc
+        verbose("File not found: %s", file);
87ab5fc
         return 0;
87ab5fc
     }
87ab5fc
 
87ab5fc
@@ -144,7 +144,7 @@ pamsshagentauth_user_key_allowed2(struct
87ab5fc
 
87ab5fc
     if(pamsshagentauth_secure_filename(f, file, pw, buf, sizeof(buf)) != 0) {
87ab5fc
         fclose(f);
87ab5fc
-        pamsshagentauth_logit("Authentication refused: %s", buf);
87ab5fc
+        logit("Authentication refused: %s", buf);
87ab5fc
         return 0;
87ab5fc
     }
87ab5fc
 
87ab5fc
@@ -187,44 +187,44 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
     else {
87ab5fc
         pw = getpwnam(authorized_keys_command_user);
87ab5fc
         if(pw == NULL) {
87ab5fc
-            pamsshagentauth_logerror("authorized_keys_command_user \"%s\" not found: %s",
87ab5fc
+            error("authorized_keys_command_user \"%s\" not found: %s",
87ab5fc
                  authorized_keys_command_user, strerror(errno));
87ab5fc
             return 0;
87ab5fc
         }
87ab5fc
     }
87ab5fc
 
87ab5fc
-    pamsshagentauth_temporarily_use_uid(pw);
87ab5fc
+    temporarily_use_uid(pw);
87ab5fc
 
87ab5fc
     if(stat(authorized_keys_command, &st) < 0) {
87ab5fc
-        pamsshagentauth_logerror
87ab5fc
+        error
87ab5fc
             ("Could not stat AuthorizedKeysCommand \"%s\": %s",
87ab5fc
              authorized_keys_command, strerror(errno));
87ab5fc
         goto out;
87ab5fc
     }
87ab5fc
     if(pamsshagentauth_auth_secure_path
87ab5fc
        (authorized_keys_command, &st, NULL, 0, errmsg, sizeof(errmsg)) != 0) {
87ab5fc
-        pamsshagentauth_logerror("Unsafe AuthorizedKeysCommand: %s", errmsg);
87ab5fc
+        error("Unsafe AuthorizedKeysCommand: %s", errmsg);
87ab5fc
         goto out;
87ab5fc
     }
87ab5fc
 
87ab5fc
     /* open the pipe and read the keys */
87ab5fc
     if(pipe(p) != 0) {
87ab5fc
-        pamsshagentauth_logerror("%s: pipe: %s", __func__, strerror(errno));
87ab5fc
+        error("%s: pipe: %s", __func__, strerror(errno));
87ab5fc
         goto out;
87ab5fc
     }
87ab5fc
 
87ab5fc
-    pamsshagentauth_debug("Running AuthorizedKeysCommand: \"%s\" as \"%s\" with argument: \"%s\"",
87ab5fc
+    debug("Running AuthorizedKeysCommand: \"%s\" as \"%s\" with argument: \"%s\"",
87ab5fc
                           authorized_keys_command, pw->pw_name, username);
87ab5fc
 
87ab5fc
     /* 
87ab5fc
      * Don't want to call this in the child, where it can fatal() and
87ab5fc
      * run cleanup_exit() code.
87ab5fc
      */
87ab5fc
-    pamsshagentauth_restore_uid();
87ab5fc
+    restore_uid();
87ab5fc
 
87ab5fc
     switch ((pid = fork())) {
87ab5fc
     case -1:                                              /* error */
87ab5fc
-        pamsshagentauth_logerror("%s: fork: %s", __func__, strerror(errno));
87ab5fc
+        error("%s: fork: %s", __func__, strerror(errno));
87ab5fc
         close(p[0]);
87ab5fc
         close(p[1]);
87ab5fc
         return 0;
87ab5fc
@@ -234,13 +234,13 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
 
87ab5fc
         /* do this before the setresuid so thta they can be logged */
87ab5fc
         if((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) {
87ab5fc
-            pamsshagentauth_logerror("%s: open %s: %s", __func__, _PATH_DEVNULL,
87ab5fc
+            error("%s: open %s: %s", __func__, _PATH_DEVNULL,
87ab5fc
                                      strerror(errno));
87ab5fc
             _exit(1);
87ab5fc
         }
87ab5fc
         if(dup2(devnull, STDIN_FILENO) == -1 || dup2(p[1], STDOUT_FILENO) == -1
87ab5fc
            || dup2(devnull, STDERR_FILENO) == -1) {
87ab5fc
-            pamsshagentauth_logerror("%s: dup2: %s", __func__, strerror(errno));
87ab5fc
+            error("%s: dup2: %s", __func__, strerror(errno));
87ab5fc
             _exit(1);
87ab5fc
         }
87ab5fc
 #if defined(HAVE_SETRESGID) && !defined(BROKEN_SETRESGID)
87ab5fc
@@ -248,7 +248,7 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
 #else
87ab5fc
         if (setgid(pw->pw_gid) != 0 || setegid(pw->pw_gid) != 0) {
87ab5fc
 #endif
87ab5fc
-            pamsshagentauth_logerror("setresgid %u: %s", (u_int) pw->pw_gid,
87ab5fc
+            error("setresgid %u: %s", (u_int) pw->pw_gid,
87ab5fc
                                      strerror(errno));
87ab5fc
             _exit(1);
87ab5fc
         }
87ab5fc
@@ -258,7 +258,7 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
 #else
87ab5fc
         if (setuid(pw->pw_uid) != 0 || seteuid(pw->pw_uid) != 0) {
87ab5fc
 #endif
87ab5fc
-            pamsshagentauth_logerror("setresuid %u: %s", (u_int) pw->pw_uid,
87ab5fc
+            error("setresuid %u: %s", (u_int) pw->pw_uid,
87ab5fc
                                      strerror(errno));
87ab5fc
             _exit(1);
87ab5fc
         }
87ab5fc
@@ -270,18 +270,18 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
 
87ab5fc
         /* pretty sure this will barf because we are now suid, but since we
87ab5fc
            should't reach this anyway, I'll leave it here */
87ab5fc
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s exec failed: %s",
87ab5fc
+        error("AuthorizedKeysCommand %s exec failed: %s",
87ab5fc
                                  authorized_keys_command, strerror(errno));
87ab5fc
         _exit(127);
87ab5fc
     default:                                              /* parent */
87ab5fc
         break;
87ab5fc
     }
87ab5fc
 
87ab5fc
-    pamsshagentauth_temporarily_use_uid(pw);
87ab5fc
+    temporarily_use_uid(pw);
87ab5fc
 
87ab5fc
     close(p[1]);
87ab5fc
     if((f = fdopen(p[0], "r")) == NULL) {
87ab5fc
-        pamsshagentauth_logerror("%s: fdopen: %s", __func__, strerror(errno));
87ab5fc
+        error("%s: fdopen: %s", __func__, strerror(errno));
87ab5fc
         close(p[0]);
87ab5fc
         /* Don't leave zombie child */
87ab5fc
         while(waitpid(pid, NULL, 0) == -1 && errno == EINTR);
87ab5fc
@@ -292,22 +292,22 @@ pamsshagentauth_user_key_command_allowed
87ab5fc
 
87ab5fc
     while(waitpid(pid, &status, 0) == -1) {
87ab5fc
         if(errno != EINTR) {
87ab5fc
-            pamsshagentauth_logerror("%s: waitpid: %s", __func__,
87ab5fc
+            error("%s: waitpid: %s", __func__,
87ab5fc
                                      strerror(errno));
87ab5fc
             goto out;
87ab5fc
         }
87ab5fc
     }
87ab5fc
     if(WIFSIGNALED(status)) {
87ab5fc
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s exited on signal %d",
87ab5fc
+        error("AuthorizedKeysCommand %s exited on signal %d",
87ab5fc
                                  authorized_keys_command, WTERMSIG(status));
87ab5fc
         goto out;
87ab5fc
     } else if(WEXITSTATUS(status) != 0) {
87ab5fc
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s returned status %d",
87ab5fc
+        error("AuthorizedKeysCommand %s returned status %d",
87ab5fc
                                  authorized_keys_command, WEXITSTATUS(status));
87ab5fc
         goto out;
87ab5fc
     }
87ab5fc
     found_key = ok;
87ab5fc
   out:
87ab5fc
-    pamsshagentauth_restore_uid();
87ab5fc
+    restore_uid();
87ab5fc
     return found_key;
87ab5fc
 }
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c.psaa-xfree openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c.psaa-xfree	2016-01-22 15:30:26.300302721 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c	2016-01-22 15:33:57.567226875 +0100
87ab5fc
@@ -117,12 +117,12 @@ parse_authorized_key_file(const char *us
87ab5fc
         } else {
87ab5fc
             slash_ptr = strchr(auth_keys_file_buf, '/');
87ab5fc
             if(!slash_ptr)
87ab5fc
-                pamsshagentauth_fatal
87ab5fc
+                fatal
87ab5fc
                     ("cannot expand tilde in path without a `/'");
87ab5fc
 
87ab5fc
             owner_uname_len = slash_ptr - auth_keys_file_buf - 1;
87ab5fc
             if(owner_uname_len > (sizeof(owner_uname) - 1))
87ab5fc
-                pamsshagentauth_fatal("Username too long");
87ab5fc
+                fatal("Username too long");
87ab5fc
 
87ab5fc
             strncat(owner_uname, auth_keys_file_buf + 1, owner_uname_len);
87ab5fc
             if(!authorized_keys_file_allowed_owner_uid)
87ab5fc
@@ -130,11 +130,11 @@ parse_authorized_key_file(const char *us
87ab5fc
                     getpwnam(owner_uname)->pw_uid;
87ab5fc
         }
87ab5fc
         authorized_keys_file =
87ab5fc
-            pamsshagentauth_tilde_expand_filename(auth_keys_file_buf,
87ab5fc
+            tilde_expand_filename(auth_keys_file_buf,
87ab5fc
                                                   authorized_keys_file_allowed_owner_uid);
87ab5fc
         strncpy(auth_keys_file_buf, authorized_keys_file,
87ab5fc
                 sizeof(auth_keys_file_buf) - 1);
87ab5fc
-        pamsshagentauth_xfree(authorized_keys_file)        /* when we
87ab5fc
+        free(authorized_keys_file)        /* when we
87ab5fc
                                                               percent_expand
87ab5fc
                                                               later, we'd step
87ab5fc
                                                               on this, so free
87ab5fc
@@ -150,7 +150,7 @@ parse_authorized_key_file(const char *us
87ab5fc
     strncat(hostname, fqdn, strcspn(fqdn, "."));
87ab5fc
 #endif
87ab5fc
     authorized_keys_file =
87ab5fc
-        pamsshagentauth_percent_expand(auth_keys_file_buf, "h",
87ab5fc
+        percent_expand(auth_keys_file_buf, "h",
87ab5fc
                                        getpwnam(user)->pw_dir, "H", hostname,
87ab5fc
                                        "f", fqdn, "u", user, NULL);
87ab5fc
 }
87ab5fc
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c.psaa-xfree openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c
87ab5fc
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c.psaa-xfree	2014-03-23 23:52:21.000000000 +0100
87ab5fc
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c	2016-01-22 15:39:26.210104334 +0100
87ab5fc
@@ -56,7 +56,7 @@ pamsshagentauth_uudecode(const char *src
87ab5fc
 	/* and remove trailing whitespace because __b64_pton needs this */
87ab5fc
 	*p = '\0';
87ab5fc
 	len = pamsshagentauth___b64_pton(encoded, target, targsize);
87ab5fc
-	pamsshagentauth_xfree(encoded);
87ab5fc
+	xfree(encoded);
87ab5fc
 	return len;
87ab5fc
 }
87ab5fc
 
87ab5fc
@@ -70,7 +70,7 @@ pamsshagentauth_dump_base64(FILE *fp, u_
87ab5fc
 		fprintf(fp, "dump_base64: len > 65536\n");
87ab5fc
 		return;
87ab5fc
 	}
87ab5fc
-	buf = pamsshagentauth_xmalloc(2*len);
87ab5fc
+	buf = malloc(2*len);
87ab5fc
 	n = pamsshagentauth_uuencode(data, len, buf, 2*len);
87ab5fc
 	for (i = 0; i < n; i++) {
87ab5fc
 		fprintf(fp, "%c", buf[i]);
87ab5fc
@@ -79,5 +79,5 @@ pamsshagentauth_dump_base64(FILE *fp, u_
87ab5fc
 	}
87ab5fc
 	if (i % 70 != 69)
87ab5fc
 		fprintf(fp, "\n");
87ab5fc
-	pamsshagentauth_xfree(buf);
87ab5fc
+	free(buf);
87ab5fc
 }
c08255b
diff --git a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
c08255b
index d5a574f..9e866c1 100644
c08255b
--- a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
c08255b
+++ b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
c08255b
@@ -68,10 +68,10 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
c08255b
 
c08255b
     /* first test if this key is even allowed */
c08255b
     if(! pam_user_key_allowed(ruser, id->key))
c08255b
-        goto user_auth_clean_exit;
c08255b
+        goto user_auth_clean_exit_without_buffer;
c08255b
 
c08255b
     if(key_to_blob(id->key, &pkblob, &blen) == 0)
c08255b
-        goto user_auth_clean_exit;
c08255b
+        goto user_auth_clean_exit_without_buffer;
c08255b
 
c08255b
     /* construct packet to sign and test */
c08255b
     buffer_init(&b);
c08255b
@@ -95,6 +95,7 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
c08255b
   user_auth_clean_exit:
c08255b
     /* if(&b != NULL) */
c08255b
     buffer_free(&b);
c08255b
+  user_auth_clean_exit_without_buffer:
c08255b
     if(sig != NULL)
c08255b
         free(sig);
c08255b
     if(pkblob != NULL)