]> andersk Git - gssapi-openssh.git/blobdiff - openssh/ssh-agent.c
merged OpenSSH 5.3p1 to trunk
[gssapi-openssh.git] / openssh / ssh-agent.c
index 6f8727b33066b5279c1705c992a8bb1a008712a3..f77dea3a63655ccae4dabc9c117b9b5252d98d5d 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.157 2007/09/25 23:48:57 canacar Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.161 2009/03/23 19:38:04 tobias Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -312,6 +312,7 @@ process_sign_request2(SocketEntry *e)
        u_char *blob, *data, *signature = NULL;
        u_int blen, dlen, slen = 0;
        extern int datafellows;
+       int odatafellows;
        int ok = -1, flags;
        Buffer msg;
        Key *key;
@@ -322,6 +323,7 @@ process_sign_request2(SocketEntry *e)
        data = buffer_get_string(&e->request, &dlen);
 
        flags = buffer_get_int(&e->request);
+       odatafellows = datafellows;
        if (flags & SSH_AGENT_OLD_SIGNATURE)
                datafellows = SSH_BUG_SIGBLOB;
 
@@ -347,6 +349,7 @@ process_sign_request2(SocketEntry *e)
        xfree(blob);
        if (signature != NULL)
                xfree(signature);
+       datafellows = odatafellows;
 }
 
 /* shared */
@@ -526,9 +529,8 @@ process_add_identity(SocketEntry *e, int version)
                xfree(comment);
                goto send;
        }
-       success = 1;
        while (buffer_len(&e->request)) {
-               switch (buffer_get_char(&e->request)) {
+               switch ((type = buffer_get_char(&e->request))) {
                case SSH_AGENT_CONSTRAIN_LIFETIME:
                        death = time(NULL) + buffer_get_int(&e->request);
                        break;
@@ -536,9 +538,14 @@ process_add_identity(SocketEntry *e, int version)
                        confirm = 1;
                        break;
                default:
-                       break;
+                       error("process_add_identity: "
+                           "Unknown constraint type %d", type);
+                       xfree(comment);
+                       key_free(k);
+                       goto send;
                }
        }
+       success = 1;
        if (lifetime && !death)
                death = time(NULL) + lifetime;
        if ((id = lookup_identity(k, version)) == NULL) {
@@ -604,10 +611,10 @@ no_identities(SocketEntry *e, u_int type)
 
 #ifdef SMARTCARD
 static void
-process_add_smartcard_key (SocketEntry *e)
+process_add_smartcard_key(SocketEntry *e)
 {
        char *sc_reader_id = NULL, *pin;
-       int i, version, success = 0, death = 0, confirm = 0;
+       int i, type, version, success = 0, death = 0, confirm = 0;
        Key **keys, *k;
        Identity *id;
        Idtab *tab;
@@ -616,7 +623,7 @@ process_add_smartcard_key (SocketEntry *e)
        pin = buffer_get_string(&e->request, NULL);
 
        while (buffer_len(&e->request)) {
-               switch (buffer_get_char(&e->request)) {
+               switch ((type = buffer_get_char(&e->request))) {
                case SSH_AGENT_CONSTRAIN_LIFETIME:
                        death = time(NULL) + buffer_get_int(&e->request);
                        break;
@@ -624,7 +631,11 @@ process_add_smartcard_key (SocketEntry *e)
                        confirm = 1;
                        break;
                default:
-                       break;
+                       error("process_add_smartcard_key: "
+                           "Unknown constraint type %d", type);
+                       xfree(sc_reader_id);
+                       xfree(pin);
+                       goto send;
                }
        }
        if (lifetime && !death)
@@ -950,7 +961,8 @@ after_select(fd_set *readset, fd_set *writeset)
                                            buffer_ptr(&sockets[i].output),
                                            buffer_len(&sockets[i].output));
                                        if (len == -1 && (errno == EAGAIN ||
-                                           errno == EINTR))
+                                           errno == EINTR ||
+                                           errno == EWOULDBLOCK))
                                                continue;
                                        break;
                                } while (1);
@@ -964,7 +976,8 @@ after_select(fd_set *readset, fd_set *writeset)
                                do {
                                        len = read(sockets[i].fd, buf, sizeof(buf));
                                        if (len == -1 && (errno == EAGAIN ||
-                                           errno == EINTR))
+                                           errno == EINTR ||
+                                           errno == EWOULDBLOCK))
                                                continue;
                                        break;
                                } while (1);
@@ -1048,6 +1061,7 @@ main(int ac, char **av)
        pid_t pid;
        char pidstrbuf[1 + 3 * sizeof pid];
        struct timeval *tvp = NULL;
+       size_t len;
 
        /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
        sanitise_stdfd();
@@ -1108,8 +1122,8 @@ main(int ac, char **av)
 
        if (ac == 0 && !c_flag && !s_flag) {
                shell = getenv("SHELL");
-               if (shell != NULL &&
-                   strncmp(shell + strlen(shell) - 3, "csh", 3) == 0)
+               if (shell != NULL && (len = strlen(shell)) > 2 &&
+                   strncmp(shell + len - 3, "csh", 3) == 0)
                        c_flag = 1;
        }
        if (k_flag) {
This page took 0.054024 seconds and 4 git commands to generate.