diff options
Diffstat (limited to 'authfile.c')
-rw-r--r-- | authfile.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/authfile.c b/authfile.c index 57dcd808c..c3a6345d3 100644 --- a/authfile.c +++ b/authfile.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfile.c,v 1.128 2018/02/23 15:58:37 markus Exp $ */ | 1 | /* $OpenBSD: authfile.c,v 1.129 2018/06/06 18:29:18 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -265,17 +265,15 @@ static int | |||
265 | sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) | 265 | sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) |
266 | { | 266 | { |
267 | FILE *f; | 267 | FILE *f; |
268 | char line[SSH_MAX_PUBKEY_BYTES]; | 268 | char *line = NULL, *cp; |
269 | char *cp; | 269 | size_t linesize = 0; |
270 | u_long linenum = 0; | ||
271 | int r; | 270 | int r; |
272 | 271 | ||
273 | if (commentp != NULL) | 272 | if (commentp != NULL) |
274 | *commentp = NULL; | 273 | *commentp = NULL; |
275 | if ((f = fopen(filename, "r")) == NULL) | 274 | if ((f = fopen(filename, "r")) == NULL) |
276 | return SSH_ERR_SYSTEM_ERROR; | 275 | return SSH_ERR_SYSTEM_ERROR; |
277 | while (read_keyfile_line(f, filename, line, sizeof(line), | 276 | while (getline(&line, &linesize, f) != -1) { |
278 | &linenum) != -1) { | ||
279 | cp = line; | 277 | cp = line; |
280 | switch (*cp) { | 278 | switch (*cp) { |
281 | case '#': | 279 | case '#': |
@@ -299,11 +297,13 @@ sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) | |||
299 | if (*commentp == NULL) | 297 | if (*commentp == NULL) |
300 | r = SSH_ERR_ALLOC_FAIL; | 298 | r = SSH_ERR_ALLOC_FAIL; |
301 | } | 299 | } |
300 | free(line); | ||
302 | fclose(f); | 301 | fclose(f); |
303 | return r; | 302 | return r; |
304 | } | 303 | } |
305 | } | 304 | } |
306 | } | 305 | } |
306 | free(line); | ||
307 | fclose(f); | 307 | fclose(f); |
308 | return SSH_ERR_INVALID_FORMAT; | 308 | return SSH_ERR_INVALID_FORMAT; |
309 | } | 309 | } |
@@ -447,19 +447,18 @@ sshkey_in_file(struct sshkey *key, const char *filename, int strict_type, | |||
447 | int check_ca) | 447 | int check_ca) |
448 | { | 448 | { |
449 | FILE *f; | 449 | FILE *f; |
450 | char line[SSH_MAX_PUBKEY_BYTES]; | 450 | char *line = NULL, *cp; |
451 | char *cp; | 451 | size_t linesize = 0; |
452 | u_long linenum = 0; | ||
453 | int r = 0; | 452 | int r = 0; |
454 | struct sshkey *pub = NULL; | 453 | struct sshkey *pub = NULL; |
454 | |||
455 | int (*sshkey_compare)(const struct sshkey *, const struct sshkey *) = | 455 | int (*sshkey_compare)(const struct sshkey *, const struct sshkey *) = |
456 | strict_type ? sshkey_equal : sshkey_equal_public; | 456 | strict_type ? sshkey_equal : sshkey_equal_public; |
457 | 457 | ||
458 | if ((f = fopen(filename, "r")) == NULL) | 458 | if ((f = fopen(filename, "r")) == NULL) |
459 | return SSH_ERR_SYSTEM_ERROR; | 459 | return SSH_ERR_SYSTEM_ERROR; |
460 | 460 | ||
461 | while (read_keyfile_line(f, filename, line, sizeof(line), | 461 | while (getline(&line, &linesize, f) != -1) { |
462 | &linenum) != -1) { | ||
463 | cp = line; | 462 | cp = line; |
464 | 463 | ||
465 | /* Skip leading whitespace. */ | 464 | /* Skip leading whitespace. */ |
@@ -491,6 +490,7 @@ sshkey_in_file(struct sshkey *key, const char *filename, int strict_type, | |||
491 | } | 490 | } |
492 | r = SSH_ERR_KEY_NOT_FOUND; | 491 | r = SSH_ERR_KEY_NOT_FOUND; |
493 | out: | 492 | out: |
493 | free(line); | ||
494 | sshkey_free(pub); | 494 | sshkey_free(pub); |
495 | fclose(f); | 495 | fclose(f); |
496 | return r; | 496 | return r; |