diff options
Diffstat (limited to 'authfd.c')
-rw-r--r-- | authfd.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* $OpenBSD: authfd.c,v 1.80 2006/08/03 03:34:41 deraadt Exp $ */ | ||
1 | /* | 2 | /* |
2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -35,16 +36,25 @@ | |||
35 | */ | 36 | */ |
36 | 37 | ||
37 | #include "includes.h" | 38 | #include "includes.h" |
38 | RCSID("$OpenBSD: authfd.c,v 1.66 2005/06/17 02:44:32 djm Exp $"); | 39 | |
40 | #include <sys/types.h> | ||
41 | #include <sys/un.h> | ||
42 | #include <sys/socket.h> | ||
39 | 43 | ||
40 | #include <openssl/evp.h> | 44 | #include <openssl/evp.h> |
41 | 45 | ||
46 | #include <openssl/crypto.h> | ||
47 | #include <fcntl.h> | ||
48 | #include <stdlib.h> | ||
49 | #include <signal.h> | ||
50 | #include <stdarg.h> | ||
51 | #include <string.h> | ||
52 | #include <unistd.h> | ||
53 | |||
54 | #include "xmalloc.h" | ||
42 | #include "ssh.h" | 55 | #include "ssh.h" |
43 | #include "rsa.h" | 56 | #include "rsa.h" |
44 | #include "buffer.h" | 57 | #include "buffer.h" |
45 | #include "bufaux.h" | ||
46 | #include "xmalloc.h" | ||
47 | #include "getput.h" | ||
48 | #include "key.h" | 58 | #include "key.h" |
49 | #include "authfd.h" | 59 | #include "authfd.h" |
50 | #include "cipher.h" | 60 | #include "cipher.h" |
@@ -52,6 +62,7 @@ RCSID("$OpenBSD: authfd.c,v 1.66 2005/06/17 02:44:32 djm Exp $"); | |||
52 | #include "compat.h" | 62 | #include "compat.h" |
53 | #include "log.h" | 63 | #include "log.h" |
54 | #include "atomicio.h" | 64 | #include "atomicio.h" |
65 | #include "misc.h" | ||
55 | 66 | ||
56 | static int agent_present = 0; | 67 | static int agent_present = 0; |
57 | 68 | ||
@@ -103,7 +114,7 @@ ssh_get_authentication_socket(void) | |||
103 | close(sock); | 114 | close(sock); |
104 | return -1; | 115 | return -1; |
105 | } | 116 | } |
106 | if (connect(sock, (struct sockaddr *) &sunaddr, sizeof sunaddr) < 0) { | 117 | if (connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr) < 0) { |
107 | close(sock); | 118 | close(sock); |
108 | return -1; | 119 | return -1; |
109 | } | 120 | } |
@@ -119,7 +130,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply | |||
119 | 130 | ||
120 | /* Get the length of the message, and format it in the buffer. */ | 131 | /* Get the length of the message, and format it in the buffer. */ |
121 | len = buffer_len(request); | 132 | len = buffer_len(request); |
122 | PUT_32BIT(buf, len); | 133 | put_u32(buf, len); |
123 | 134 | ||
124 | /* Send the length and then the packet to the agent. */ | 135 | /* Send the length and then the packet to the agent. */ |
125 | if (atomicio(vwrite, auth->fd, buf, 4) != 4 || | 136 | if (atomicio(vwrite, auth->fd, buf, 4) != 4 || |
@@ -138,7 +149,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply | |||
138 | } | 149 | } |
139 | 150 | ||
140 | /* Extract the length, and check it for sanity. */ | 151 | /* Extract the length, and check it for sanity. */ |
141 | len = GET_32BIT(buf); | 152 | len = get_u32(buf); |
142 | if (len > 256 * 1024) | 153 | if (len > 256 * 1024) |
143 | fatal("Authentication response too long: %u", len); | 154 | fatal("Authentication response too long: %u", len); |
144 | 155 | ||
@@ -335,7 +346,6 @@ ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int versio | |||
335 | break; | 346 | break; |
336 | default: | 347 | default: |
337 | return NULL; | 348 | return NULL; |
338 | break; | ||
339 | } | 349 | } |
340 | /* Decrement the number of remaining entries. */ | 350 | /* Decrement the number of remaining entries. */ |
341 | auth->howmany--; | 351 | auth->howmany--; |
@@ -394,7 +404,7 @@ ssh_decrypt_challenge(AuthenticationConnection *auth, | |||
394 | * fatal error if the packet is corrupt. | 404 | * fatal error if the packet is corrupt. |
395 | */ | 405 | */ |
396 | for (i = 0; i < 16; i++) | 406 | for (i = 0; i < 16; i++) |
397 | response[i] = buffer_get_char(&buffer); | 407 | response[i] = (u_char)buffer_get_char(&buffer); |
398 | } | 408 | } |
399 | buffer_free(&buffer); | 409 | buffer_free(&buffer); |
400 | return success; | 410 | return success; |
@@ -517,7 +527,6 @@ ssh_add_identity_constrained(AuthenticationConnection *auth, Key *key, | |||
517 | default: | 527 | default: |
518 | buffer_free(&msg); | 528 | buffer_free(&msg); |
519 | return 0; | 529 | return 0; |
520 | break; | ||
521 | } | 530 | } |
522 | if (constrained) { | 531 | if (constrained) { |
523 | if (life != 0) { | 532 | if (life != 0) { |