diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | authfile.c | 26 |
2 files changed, 16 insertions, 13 deletions
@@ -9,6 +9,9 @@ | |||
9 | ssh-dss.h ssh-keygen.1 ssh-keyscan.1 ssh-rsa.h ssh1.h ssh_config | 9 | ssh-dss.h ssh-keygen.1 ssh-keyscan.1 ssh-rsa.h ssh1.h ssh_config |
10 | sshconnect.h sshd_config tildexpand.h uidswap.h uuencode.h] | 10 | sshconnect.h sshd_config tildexpand.h uidswap.h uuencode.h] |
11 | $OpenBSD$ | 11 | $OpenBSD$ |
12 | - stevesk@cvs.openbsd.org 2001/01/28 22:27:05 | ||
13 | [authfile.c] | ||
14 | spelling. use sizeof vs. strlen(). ok markus@ | ||
12 | 15 | ||
13 | 20010126 | 16 | 20010126 |
14 | - (bal) SSH_PROGRAM vs _PATH_SSH_PROGRAM fix pointed out by Roumen | 17 | - (bal) SSH_PROGRAM vs _PATH_SSH_PROGRAM fix pointed out by Roumen |
diff --git a/authfile.c b/authfile.c index c79b2d021..8d39e32e4 100644 --- a/authfile.c +++ b/authfile.c | |||
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | RCSID("$OpenBSD: authfile.c,v 1.25 2001/01/21 19:05:44 markus Exp $"); | 39 | RCSID("$OpenBSD: authfile.c,v 1.26 2001/01/28 22:27:05 stevesk Exp $"); |
40 | 40 | ||
41 | #include <openssl/err.h> | 41 | #include <openssl/err.h> |
42 | #include <openssl/evp.h> | 42 | #include <openssl/evp.h> |
@@ -51,7 +51,8 @@ RCSID("$OpenBSD: authfile.c,v 1.25 2001/01/21 19:05:44 markus Exp $"); | |||
51 | #include "log.h" | 51 | #include "log.h" |
52 | 52 | ||
53 | /* Version identification string for identity files. */ | 53 | /* Version identification string for identity files. */ |
54 | #define AUTHFILE_ID_STRING "SSH PRIVATE KEY FILE FORMAT 1.1\n" | 54 | static const char authfile_id_string[] = |
55 | "SSH PRIVATE KEY FILE FORMAT 1.1\n"; | ||
55 | 56 | ||
56 | /* | 57 | /* |
57 | * Saves the authentication (private) key in a file, encrypting it with | 58 | * Saves the authentication (private) key in a file, encrypting it with |
@@ -111,9 +112,8 @@ save_private_key_rsa1(const char *filename, const char *passphrase, | |||
111 | buffer_init(&encrypted); | 112 | buffer_init(&encrypted); |
112 | 113 | ||
113 | /* First store keyfile id string. */ | 114 | /* First store keyfile id string. */ |
114 | cp = AUTHFILE_ID_STRING; | 115 | for (i = 0; authfile_id_string[i]; i++) |
115 | for (i = 0; cp[i]; i++) | 116 | buffer_put_char(&encrypted, authfile_id_string[i]); |
116 | buffer_put_char(&encrypted, cp[i]); | ||
117 | buffer_put_char(&encrypted, 0); | 117 | buffer_put_char(&encrypted, 0); |
118 | 118 | ||
119 | /* Store cipher type. */ | 119 | /* Store cipher type. */ |
@@ -247,8 +247,8 @@ load_public_key_rsa(const char *filename, RSA * pub, char **comment_return) | |||
247 | } | 247 | } |
248 | close(fd); | 248 | close(fd); |
249 | 249 | ||
250 | /* Check that it is at least big enought to contain the ID string. */ | 250 | /* Check that it is at least big enough to contain the ID string. */ |
251 | if (len < strlen(AUTHFILE_ID_STRING) + 1) { | 251 | if (len < sizeof(authfile_id_string)) { |
252 | debug3("Bad RSA1 key file %.200s.", filename); | 252 | debug3("Bad RSA1 key file %.200s.", filename); |
253 | buffer_free(&buffer); | 253 | buffer_free(&buffer); |
254 | return 0; | 254 | return 0; |
@@ -257,8 +257,8 @@ load_public_key_rsa(const char *filename, RSA * pub, char **comment_return) | |||
257 | * Make sure it begins with the id string. Consume the id string | 257 | * Make sure it begins with the id string. Consume the id string |
258 | * from the buffer. | 258 | * from the buffer. |
259 | */ | 259 | */ |
260 | for (i = 0; i < (u_int) strlen(AUTHFILE_ID_STRING) + 1; i++) | 260 | for (i = 0; i < sizeof(authfile_id_string); i++) |
261 | if (buffer_get_char(&buffer) != (u_char) AUTHFILE_ID_STRING[i]) { | 261 | if (buffer_get_char(&buffer) != authfile_id_string[i]) { |
262 | debug3("Bad RSA1 key file %.200s.", filename); | 262 | debug3("Bad RSA1 key file %.200s.", filename); |
263 | buffer_free(&buffer); | 263 | buffer_free(&buffer); |
264 | return 0; | 264 | return 0; |
@@ -337,8 +337,8 @@ load_private_key_rsa1(int fd, const char *filename, | |||
337 | } | 337 | } |
338 | close(fd); | 338 | close(fd); |
339 | 339 | ||
340 | /* Check that it is at least big enought to contain the ID string. */ | 340 | /* Check that it is at least big enough to contain the ID string. */ |
341 | if (len < strlen(AUTHFILE_ID_STRING) + 1) { | 341 | if (len < sizeof(authfile_id_string)) { |
342 | debug3("Bad RSA1 key file %.200s.", filename); | 342 | debug3("Bad RSA1 key file %.200s.", filename); |
343 | buffer_free(&buffer); | 343 | buffer_free(&buffer); |
344 | return 0; | 344 | return 0; |
@@ -347,8 +347,8 @@ load_private_key_rsa1(int fd, const char *filename, | |||
347 | * Make sure it begins with the id string. Consume the id string | 347 | * Make sure it begins with the id string. Consume the id string |
348 | * from the buffer. | 348 | * from the buffer. |
349 | */ | 349 | */ |
350 | for (i = 0; i < (u_int) strlen(AUTHFILE_ID_STRING) + 1; i++) | 350 | for (i = 0; i < sizeof(authfile_id_string); i++) |
351 | if (buffer_get_char(&buffer) != (u_char) AUTHFILE_ID_STRING[i]) { | 351 | if (buffer_get_char(&buffer) != authfile_id_string[i]) { |
352 | debug3("Bad RSA1 key file %.200s.", filename); | 352 | debug3("Bad RSA1 key file %.200s.", filename); |
353 | buffer_free(&buffer); | 353 | buffer_free(&buffer); |
354 | return 0; | 354 | return 0; |