diff options
| author | christos <christos@NetBSD.org> | 2016-06-05 17:43:02 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2016-06-05 17:43:02 +0000 |
| commit | 8cc665c547c4e2d4ac0662f103f3ffbe92c8190c (patch) | |
| tree | 3a72b1512bfd165fc1f9d1550747868b5a0abceb /sys | |
| parent | 3d58708caee382e5bf5168bae5c9f4684b4169ae (diff) | |
get rid of gets/tgets
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/hp300/stand/common/netio.c | 12 | ||||
| -rw-r--r-- | sys/arch/hp300/stand/common/samachdep.h | 4 | ||||
| -rw-r--r-- | sys/arch/hp300/stand/common/tgets.c | 9 | ||||
| -rw-r--r-- | sys/arch/hp300/stand/uboot/uboot.c | 4 |
4 files changed, 17 insertions, 12 deletions
diff --git a/sys/arch/hp300/stand/common/netio.c b/sys/arch/hp300/stand/common/netio.c index 6e769b82305..c5225d520ba 100644 --- a/sys/arch/hp300/stand/common/netio.c +++ b/sys/arch/hp300/stand/common/netio.c @@ -1,4 +1,4 @@ -/* $NetBSD: netio.c,v 1.14 2011/07/17 20:54:40 joerg Exp $ */ +/* $NetBSD: netio.c,v 1.15 2016/06/05 17:43:02 christos Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -169,7 +169,7 @@ netmountroot(struct open_file *f, char *devname) get_my_ip: printf("My IP address? "); memset(input_line, 0, sizeof(input_line)); - gets(input_line); + gets_s(input_line, sizeof(input_line)); if ((myip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { printf("invalid IP address: %s\n", input_line); @@ -179,7 +179,7 @@ netmountroot(struct open_file *f, char *devname) get_my_netmask: printf("My netmask? "); memset(input_line, 0, sizeof(input_line)); - gets(input_line); + gets_s(input_line, sizeof(input_line)); if ((netmask = inet_addr(input_line)) == htonl(INADDR_NONE)) { printf("invalid netmask: %s\n", input_line); @@ -189,7 +189,7 @@ netmountroot(struct open_file *f, char *devname) get_my_gateway: printf("My gateway? "); memset(input_line, 0, sizeof(input_line)); - gets(input_line); + gets_s(input_line, sizeof(input_line)); if ((gateip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { printf("invalid IP address: %s\n", input_line); @@ -199,7 +199,7 @@ netmountroot(struct open_file *f, char *devname) get_server_ip: printf("Server IP address? "); memset(input_line, 0, sizeof(input_line)); - gets(input_line); + gets_s(input_line, sizeof(input_line)); if ((rootip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { printf("invalid IP address: %s\n", input_line); @@ -209,7 +209,7 @@ netmountroot(struct open_file *f, char *devname) get_server_path: printf("Server path? "); memset(rootpath, 0, sizeof(rootpath)); - gets(rootpath); + gets_s(rootpath, sizeof(rootpath)); if (rootpath[0] == '\0' || rootpath[0] == '\n') goto get_server_path; diff --git a/sys/arch/hp300/stand/common/samachdep.h b/sys/arch/hp300/stand/common/samachdep.h index b0b32ae2a10..4f65b6bc9c6 100644 --- a/sys/arch/hp300/stand/common/samachdep.h +++ b/sys/arch/hp300/stand/common/samachdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: samachdep.h,v 1.18 2014/08/10 07:40:49 isaki Exp $ */ +/* $NetBSD: samachdep.h,v 1.19 2016/06/05 17:43:02 christos Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -98,7 +98,7 @@ void romout(int, char *); void _transfer(char *, int, int, int, char *, char *); /* tget.c */ -int tgets(char *); +int tgets_s(char *, size_t); #define DELAY(n) \ diff --git a/sys/arch/hp300/stand/common/tgets.c b/sys/arch/hp300/stand/common/tgets.c index 79fe49c7e74..283e7bf711c 100644 --- a/sys/arch/hp300/stand/common/tgets.c +++ b/sys/arch/hp300/stand/common/tgets.c @@ -1,4 +1,4 @@ -/* $NetBSD: tgets.c,v 1.5 2005/12/11 12:17:19 christos Exp $ */ +/* $NetBSD: tgets.c,v 1.6 2016/06/05 17:43:02 christos Exp $ */ /*- * Copyright (c) 1993 @@ -38,13 +38,18 @@ #include <hp300/stand/common/samachdep.h> int -tgets(char *buf) +tgets_s(char *buf, size_t size) { int c; int i; char *lp = buf; for (i = 240000; i > 0; i--) { + if (lp - buf == size) { + lp--; + *lp = '\0'; + return; + } c = tgetchar() & 0177; if (c) { for (;;) { diff --git a/sys/arch/hp300/stand/uboot/uboot.c b/sys/arch/hp300/stand/uboot/uboot.c index b71a2d6cfa7..de0966b5f82 100644 --- a/sys/arch/hp300/stand/uboot/uboot.c +++ b/sys/arch/hp300/stand/uboot/uboot.c @@ -1,4 +1,4 @@ -/* $NetBSD: uboot.c,v 1.15 2008/07/16 13:44:51 tsutsui Exp $ */ +/* $NetBSD: uboot.c,v 1.16 2016/06/05 17:43:02 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -109,7 +109,7 @@ getbootdev(int *howto) printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ", devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name); - if (tgets(line)) { + if (tgets_s(line, sizeof(line))) { if (strcmp(line, "reset") == 0) { call_req_reboot(); /* reset machine */ printf("panic: can't reboot, halting\n"); |
