Module Name:    src
Committed By:   christos
Date:           Sun Jun  5 17:43:02 UTC 2016

Modified Files:
        src/sys/arch/hp300/stand/common: netio.c samachdep.h tgets.c
        src/sys/arch/hp300/stand/uboot: uboot.c

Log Message:
get rid of gets/tgets


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp300/stand/common/netio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/hp300/stand/common/samachdep.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hp300/stand/common/tgets.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hp300/stand/uboot/uboot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hp300/stand/common/netio.c
diff -u src/sys/arch/hp300/stand/common/netio.c:1.14 src/sys/arch/hp300/stand/common/netio.c:1.15
--- src/sys/arch/hp300/stand/common/netio.c:1.14	Sun Jul 17 16:54:40 2011
+++ src/sys/arch/hp300/stand/common/netio.c	Sun Jun  5 13:43:02 2016
@@ -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 *
  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 *
  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 *
  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 *
  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 *
  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;
 

Index: src/sys/arch/hp300/stand/common/samachdep.h
diff -u src/sys/arch/hp300/stand/common/samachdep.h:1.18 src/sys/arch/hp300/stand/common/samachdep.h:1.19
--- src/sys/arch/hp300/stand/common/samachdep.h:1.18	Sun Aug 10 03:40:49 2014
+++ src/sys/arch/hp300/stand/common/samachdep.h	Sun Jun  5 13:43:02 2016
@@ -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)							\

Index: src/sys/arch/hp300/stand/common/tgets.c
diff -u src/sys/arch/hp300/stand/common/tgets.c:1.5 src/sys/arch/hp300/stand/common/tgets.c:1.6
--- src/sys/arch/hp300/stand/common/tgets.c:1.5	Sun Dec 11 07:17:19 2005
+++ src/sys/arch/hp300/stand/common/tgets.c	Sun Jun  5 13:43:02 2016
@@ -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 (;;) {

Index: src/sys/arch/hp300/stand/uboot/uboot.c
diff -u src/sys/arch/hp300/stand/uboot/uboot.c:1.15 src/sys/arch/hp300/stand/uboot/uboot.c:1.16
--- src/sys/arch/hp300/stand/uboot/uboot.c:1.15	Wed Jul 16 09:44:51 2008
+++ src/sys/arch/hp300/stand/uboot/uboot.c	Sun Jun  5 13:43:02 2016
@@ -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");

Reply via email to