summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2007-09-17 16:09:15 +1000
committerDamien Miller <djm@mindrot.org>2007-09-17 16:09:15 +1000
commit14b017d6f2277c83856489054e9c6c1428095bbb (patch)
treecc10c13ca8483de9ec16695a35de2355c90c29ef /ssh-keygen.c
parent9c89c837ccfeafb09f3d6fb463942fc919f3dc29 (diff)
- gilles@cvs.openbsd.org 2007/09/11 15:47:17
[session.c ssh-keygen.c sshlogin.c] use strcspn to properly overwrite '\n' in fgets returned buffer ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 95b0ac850..2b2399c50 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.161 2007/09/09 11:38:01 sobrado Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.162 2007/09/11 15:47:17 gilles 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
@@ -141,8 +141,7 @@ ask_filename(struct passwd *pw, const char *prompt)
141 fprintf(stderr, "%s (%s): ", prompt, identity_file); 141 fprintf(stderr, "%s (%s): ", prompt, identity_file);
142 if (fgets(buf, sizeof(buf), stdin) == NULL) 142 if (fgets(buf, sizeof(buf), stdin) == NULL)
143 exit(1); 143 exit(1);
144 if (strchr(buf, '\n')) 144 buf[strcspn(buf, "\n")] = '\0';
145 *strchr(buf, '\n') = 0;
146 if (strcmp(buf, "") != 0) 145 if (strcmp(buf, "") != 0)
147 strlcpy(identity_file, buf, sizeof(identity_file)); 146 strlcpy(identity_file, buf, sizeof(identity_file));
148 have_identity = 1; 147 have_identity = 1;
@@ -962,8 +961,7 @@ do_change_comment(struct passwd *pw)
962 key_free(private); 961 key_free(private);
963 exit(1); 962 exit(1);
964 } 963 }
965 if (strchr(new_comment, '\n')) 964 new_comment[strcspn(new_comment, "\n")] = '\0';
966 *strchr(new_comment, '\n') = 0;
967 } 965 }
968 966
969 /* Save the file using the new passphrase. */ 967 /* Save the file using the new passphrase. */