summaryrefslogtreecommitdiff
path: root/auth2-pubkey.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2018-06-06 18:29:18 +0000
committerDamien Miller <djm@mindrot.org>2018-06-07 04:34:05 +1000
commit7f90635216851f6cb4bf3999e98b825f85d604f8 (patch)
treeac302db18a71c1e3c5d9077d1a820e37fbc2b9b5 /auth2-pubkey.c
parent392db2bc83215986a91c0b65feb0e40e7619ce7e (diff)
upstream: switch config file parsing to getline(3) as this avoids
static limits noted by gerhard@; ok dtucker@, djm@ OpenBSD-Commit-ID: 6d702eabef0fa12e5a1d75c334a8c8b325298b5c
Diffstat (limited to 'auth2-pubkey.c')
-rw-r--r--auth2-pubkey.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 5603f5ef3..3ccc3a213 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-pubkey.c,v 1.78 2018/06/01 03:33:53 djm Exp $ */ 1/* $OpenBSD: auth2-pubkey.c,v 1.79 2018/06/06 18:29:18 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -319,14 +319,16 @@ static int
319process_principals(struct ssh *ssh, FILE *f, const char *file, 319process_principals(struct ssh *ssh, FILE *f, const char *file,
320 const struct sshkey_cert *cert, struct sshauthopt **authoptsp) 320 const struct sshkey_cert *cert, struct sshauthopt **authoptsp)
321{ 321{
322 char loc[256], line[SSH_MAX_PUBKEY_BYTES], *cp, *ep; 322 char loc[256], *line = NULL, *cp, *ep;
323 size_t linesize = 0;
323 u_long linenum = 0; 324 u_long linenum = 0;
324 u_int found_principal = 0; 325 u_int found_principal = 0;
325 326
326 if (authoptsp != NULL) 327 if (authoptsp != NULL)
327 *authoptsp = NULL; 328 *authoptsp = NULL;
328 329
329 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { 330 while (getline(&line, &linesize, f) != -1) {
331 linenum++;
330 /* Always consume entire input */ 332 /* Always consume entire input */
331 if (found_principal) 333 if (found_principal)
332 continue; 334 continue;
@@ -344,6 +346,7 @@ process_principals(struct ssh *ssh, FILE *f, const char *file,
344 if (check_principals_line(ssh, cp, cert, loc, authoptsp) == 0) 346 if (check_principals_line(ssh, cp, cert, loc, authoptsp) == 0)
345 found_principal = 1; 347 found_principal = 1;
346 } 348 }
349 free(line);
347 return found_principal; 350 return found_principal;
348} 351}
349 352
@@ -687,14 +690,16 @@ static int
687check_authkeys_file(struct ssh *ssh, struct passwd *pw, FILE *f, 690check_authkeys_file(struct ssh *ssh, struct passwd *pw, FILE *f,
688 char *file, struct sshkey *key, struct sshauthopt **authoptsp) 691 char *file, struct sshkey *key, struct sshauthopt **authoptsp)
689{ 692{
690 char *cp, line[SSH_MAX_PUBKEY_BYTES], loc[256]; 693 char *cp, *line = NULL, loc[256];
694 size_t linesize = 0;
691 int found_key = 0; 695 int found_key = 0;
692 u_long linenum = 0; 696 u_long linenum = 0;
693 697
694 if (authoptsp != NULL) 698 if (authoptsp != NULL)
695 *authoptsp = NULL; 699 *authoptsp = NULL;
696 700
697 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { 701 while (getline(&line, &linesize, f) != -1) {
702 linenum++;
698 /* Always consume entire file */ 703 /* Always consume entire file */
699 if (found_key) 704 if (found_key)
700 continue; 705 continue;
@@ -708,6 +713,7 @@ check_authkeys_file(struct ssh *ssh, struct passwd *pw, FILE *f,
708 if (check_authkey_line(ssh, pw, key, cp, loc, authoptsp) == 0) 713 if (check_authkey_line(ssh, pw, key, cp, loc, authoptsp) == 0)
709 found_key = 1; 714 found_key = 1;
710 } 715 }
716 free(line);
711 return found_key; 717 return found_key;
712} 718}
713 719