Index: vfs_mount.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_mount.c,v retrieving revision 1.109 diff -u -r1.109 vfs_mount.c --- vfs_mount.c 2003/07/01 17:40:23 1.109 +++ vfs_mount.c 2003/07/16 01:41:52 @@ -103,7 +103,7 @@ static int vfs_nmount(struct thread *td, int, struct uio *); static int vfs_mountroot_try(char *mountfrom); static int vfs_mountroot_ask(void); -static void gets(char *cp); +static void gets(char *cp, int len); static int usermount = 0; /* if 1, non-root can mount fs. */ SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -1622,7 +1622,7 @@ printf(" ? List valid disk boot devices\n"); printf(" Abort manual input\n"); printf("\nmountroot> "); - gets(name); + gets(name, sizeof name); if (name[0] == 0) return(1); if (name[0] == '?') { @@ -1639,14 +1639,14 @@ * Local helper function for vfs_mountroot_ask. */ static void -gets(char *cp) +gets(char *cp, int len) { char *lp; int c; lp = cp; - for (;;) { - printf("%c", c = cngetc() & 0177); + for (;lp < cp + len;) { + printf("%c", (char)(c = cngetc()) & 0177); switch (c) { case -1: case '\n': @@ -1671,9 +1671,13 @@ printf("%c", '\n'); continue; default: - *lp++ = c; + *lp++ = c & 0177; } } + if (lp >= cp + len) + *(cp + len - 1) = '\0'; + else + *lp = '\0'; } /*