]> andersk Git - openssh.git/blobdiff - authfd.c
- deraadt@cvs.openbsd.org 2006/03/19 18:51:18
[openssh.git] / authfd.c
index 6a7c072056230c6c0e4ac76108667a2100da5d81..a3f22cfc7c6513123fbc133b403435b9c68d57f7 100644 (file)
--- a/authfd.c
+++ b/authfd.c
@@ -35,7 +35,9 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: authfd.c,v 1.63 2003/11/21 11:57:03 djm Exp $");
+
+#include <sys/types.h>
+#include <sys/un.h>
 
 #include <openssl/evp.h>
 
@@ -114,8 +116,7 @@ ssh_get_authentication_socket(void)
 static int
 ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply)
 {
-       int l;
-       u_int len;
+       u_int l, len;
        char buf[1024];
 
        /* Get the length of the message, and format it in the buffer. */
@@ -133,16 +134,9 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
         * Wait for response from the agent.  First read the length of the
         * response packet.
         */
-       len = 4;
-       while (len > 0) {
-               l = read(auth->fd, buf + 4 - len, len);
-               if (l == -1 && (errno == EAGAIN || errno == EINTR))
-                       continue;
-               if (l <= 0) {
-                       error("Error reading response length from authentication socket.");
-                       return 0;
-               }
-               len -= l;
+       if (atomicio(read, auth->fd, buf, 4) != 4) {
+           error("Error reading response length from authentication socket.");
+           return 0;
        }
 
        /* Extract the length, and check it for sanity. */
@@ -156,10 +150,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
                l = len;
                if (l > sizeof(buf))
                        l = sizeof(buf);
-               l = read(auth->fd, buf, l);
-               if (l == -1 && (errno == EAGAIN || errno == EINTR))
-                       continue;
-               if (l <= 0) {
+               if (atomicio(read, auth->fd, buf, l) != l) {
                        error("Error reading response from authentication socket.");
                        return 0;
                }
@@ -312,6 +303,7 @@ ssh_get_first_identity(AuthenticationConnection *auth, char **comment, int versi
 Key *
 ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int version)
 {
+       int keybits;
        u_int bits;
        u_char *blob;
        u_int blen;
@@ -332,7 +324,8 @@ ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int versio
                buffer_get_bignum(&auth->identities, key->rsa->e);
                buffer_get_bignum(&auth->identities, key->rsa->n);
                *comment = buffer_get_string(&auth->identities, NULL);
-               if (bits != BN_num_bits(key->rsa->n))
+               keybits = BN_num_bits(key->rsa->n);
+               if (keybits < 0 || bits != (u_int)keybits)
                        logit("Warning: identity keysize mismatch: actual %d, announced %u",
                            BN_num_bits(key->rsa->n), bits);
                break;
@@ -607,7 +600,7 @@ ssh_update_card(AuthenticationConnection *auth, int add,
        buffer_put_char(&msg, type);
        buffer_put_cstring(&msg, reader_id);
        buffer_put_cstring(&msg, pin);
-       
+
        if (constrained) {
                if (life != 0) {
                        buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME);
This page took 0.034945 seconds and 4 git commands to generate.