Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/skeyinit Filter out non-alpha-numeric characters fro...
details: https://anonhg.NetBSD.org/src/rev/bf2d03f31f1b
branches: trunk
changeset: 495467:bf2d03f31f1b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri Jul 28 19:19:23 2000 +0000
description:
Filter out non-alpha-numeric characters from the default
seed. No point in generating one that skey(1) will reject.
diffstat:
usr.bin/skeyinit/skeyinit.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diffs (31 lines):
diff -r 2a0d5aeff0d6 -r bf2d03f31f1b usr.bin/skeyinit/skeyinit.c
--- a/usr.bin/skeyinit/skeyinit.c Fri Jul 28 19:17:02 2000 +0000
+++ b/usr.bin/skeyinit/skeyinit.c Fri Jul 28 19:19:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: skeyinit.c,v 1.13 2000/07/07 00:18:29 mjl Exp $ */
+/* $NetBSD: skeyinit.c,v 1.14 2000/07/28 19:19:23 thorpej Exp $ */
/* S/KEY v1.1b (skeyinit.c)
*
@@ -58,7 +58,20 @@
if (gethostname(hostname, sizeof(hostname)) < 0)
err(1, "gethostname");
- (void)strncpy(defaultseed, hostname, sizeof(defaultseed)- 1);
+
+ /*
+ * Copy the hostname into the default seed, eliminating any
+ * non alpha-numeric characters.
+ */
+ for (i = 0, l = 0; l < sizeof(defaultseed); i++) {
+ if (hostname[i] == '\0') {
+ defaultseed[l] = hostname[i];
+ break;
+ }
+ if (isalnum(hostname[i]))
+ defaultseed[l++] = hostname[i];
+ }
+
defaultseed[SKEY_NAMELEN] = '\0';
(void)time(&now);
(void)sprintf(tbuf, "%05ld", (long) (now % 100000));
Home |
Main Index |
Thread Index |
Old Index