summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2007-10-26 14:26:32 +1000
committerDamien Miller <djm@mindrot.org>2007-10-26 14:26:32 +1000
commit0f4ed693d655429ad544b36c7305216d155a2d4b (patch)
tree39db4ff797fc1199990b0f1735b8af47ccc509b2
parentb8c98076283a43e21dc53580837f3296c186ecd6 (diff)
- chl@cvs.openbsd.org 2007/10/02 17:49:58
[ssh-keygen.c] handles zero-sized strings that fgets can return
-rw-r--r--ChangeLog5
-rw-r--r--ssh-keygen.c16
2 files changed, 11 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c5b78e75..a3cc1058b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,9 @@
30 - dtucker@cvs.openbsd.org 2007/09/29 00:25:51 30 - dtucker@cvs.openbsd.org 2007/09/29 00:25:51
31 [auth2.c] 31 [auth2.c]
32 Remove unused prototype. ok djm@ 32 Remove unused prototype. ok djm@
33 - chl@cvs.openbsd.org 2007/10/02 17:49:58
34 [ssh-keygen.c]
35 handles zero-sized strings that fgets can return
33 36
3420070927 3720070927
35 - (dtucker) [configure.ac atomicio.c] Fall back to including <sys/poll.h> if 38 - (dtucker) [configure.ac atomicio.c] Fall back to including <sys/poll.h> if
@@ -3301,4 +3304,4 @@
3301 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3304 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3302 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3305 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3303 3306
3304$Id: ChangeLog,v 1.4766 2007/10/26 04:26:15 djm Exp $ 3307$Id: ChangeLog,v 1.4767 2007/10/26 04:26:32 djm Exp $
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 2b2399c50..657937629 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.162 2007/09/11 15:47:17 gilles Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.163 2007/10/02 17:49:58 chl Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -535,8 +535,7 @@ do_fingerprint(struct passwd *pw)
535 f = fopen(identity_file, "r"); 535 f = fopen(identity_file, "r");
536 if (f != NULL) { 536 if (f != NULL) {
537 while (fgets(line, sizeof(line), f)) { 537 while (fgets(line, sizeof(line), f)) {
538 i = strlen(line) - 1; 538 if ((cp = strchr(line, '\n')) == NULL) {
539 if (line[i] != '\n') {
540 error("line %d too long: %.40s...", num, line); 539 error("line %d too long: %.40s...", num, line);
541 skip = 1; 540 skip = 1;
542 continue; 541 continue;
@@ -546,7 +545,7 @@ do_fingerprint(struct passwd *pw)
546 skip = 0; 545 skip = 0;
547 continue; 546 continue;
548 } 547 }
549 line[i] = '\0'; 548 *cp = '\0';
550 549
551 /* Skip leading whitespace, empty and comment lines. */ 550 /* Skip leading whitespace, empty and comment lines. */
552 for (cp = line; *cp == ' ' || *cp == '\t'; cp++) 551 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
@@ -614,7 +613,7 @@ do_known_hosts(struct passwd *pw, const char *name)
614 Key *public; 613 Key *public;
615 char *cp, *cp2, *kp, *kp2; 614 char *cp, *cp2, *kp, *kp2;
616 char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; 615 char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN];
617 int c, i, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; 616 int c, skip = 0, inplace = 0, num = 1, invalid = 0, has_unhashed = 0;
618 617
619 if (!have_identity) { 618 if (!have_identity) {
620 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); 619 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid);
@@ -649,19 +648,18 @@ do_known_hosts(struct passwd *pw, const char *name)
649 } 648 }
650 649
651 while (fgets(line, sizeof(line), in)) { 650 while (fgets(line, sizeof(line), in)) {
652 num++; 651 if ((cp = strchr(line, '\n')) == NULL) {
653 i = strlen(line) - 1;
654 if (line[i] != '\n') {
655 error("line %d too long: %.40s...", num, line); 652 error("line %d too long: %.40s...", num, line);
656 skip = 1; 653 skip = 1;
657 invalid = 1; 654 invalid = 1;
658 continue; 655 continue;
659 } 656 }
657 num++;
660 if (skip) { 658 if (skip) {
661 skip = 0; 659 skip = 0;
662 continue; 660 continue;
663 } 661 }
664 line[i] = '\0'; 662 *cp = '\0';
665 663
666 /* Skip leading whitespace, empty and comment lines. */ 664 /* Skip leading whitespace, empty and comment lines. */
667 for (cp = line; *cp == ' ' || *cp == '\t'; cp++) 665 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)