Module Name:    src
Committed By:   dholland
Date:           Sat Jun 11 06:49:46 UTC 2016

Modified Files:
        src/sys/arch/sun68k/stand/libsa: gets.c xxboot.c
        src/sys/arch/sun68k/stand/tapeboot: boot.c

Log Message:
PR 51200 gets in libsa considered harmful: change own gets() to kgets()
and use it.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sun68k/stand/libsa/gets.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sun68k/stand/libsa/xxboot.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sun68k/stand/tapeboot/boot.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/sun68k/stand/libsa/gets.c
diff -u src/sys/arch/sun68k/stand/libsa/gets.c:1.4 src/sys/arch/sun68k/stand/libsa/gets.c:1.5
--- src/sys/arch/sun68k/stand/libsa/gets.c:1.4	Sun Dec 11 12:19:29 2005
+++ src/sys/arch/sun68k/stand/libsa/gets.c	Sat Jun 11 06:49:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: gets.c,v 1.4 2005/12/11 12:19:29 christos Exp $	*/
+/*	$NetBSD: gets.c,v 1.5 2016/06/11 06:49:46 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -45,7 +45,7 @@
  */
 
 void 
-gets(char *buf)
+kgets(char *buf, size_t size)
 {
 	int c;
 	char *lp;
@@ -54,6 +54,11 @@ top:
 	lp = buf;
 
 	for (;;) {
+		if (lp - buf == size) {
+			lp--;
+			*lp = '\0';
+			return;
+		}
 		c = getchar() & 0177;
 
 #ifdef	GETS_MUST_ECHO	/* Preserved in case someone wants it... */

Index: src/sys/arch/sun68k/stand/libsa/xxboot.c
diff -u src/sys/arch/sun68k/stand/libsa/xxboot.c:1.6 src/sys/arch/sun68k/stand/libsa/xxboot.c:1.7
--- src/sys/arch/sun68k/stand/libsa/xxboot.c:1.6	Mon Jan 12 07:01:00 2009
+++ src/sys/arch/sun68k/stand/libsa/xxboot.c	Sat Jun 11 06:49:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xxboot.c,v 1.6 2009/01/12 07:01:00 tsutsui Exp $ */
+/*	$NetBSD: xxboot.c,v 1.7 2016/06/11 06:49:46 dholland Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -133,7 +133,7 @@ xxboot_main(const char *boot_type)
 	just_ask:
 		file = kernelnames[0];
 		printf("filename? [%s]: ", file);
-		gets(line);
+		kgets(line, sizeof(line));
 		if (line[0])
 			file = line;
 

Index: src/sys/arch/sun68k/stand/tapeboot/boot.c
diff -u src/sys/arch/sun68k/stand/tapeboot/boot.c:1.7 src/sys/arch/sun68k/stand/tapeboot/boot.c:1.8
--- src/sys/arch/sun68k/stand/tapeboot/boot.c:1.7	Sun May 29 10:15:30 2011
+++ src/sys/arch/sun68k/stand/tapeboot/boot.c	Sat Jun 11 06:49:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.7 2011/05/29 10:15:30 tsutsui Exp $ */
+/*	$NetBSD: boot.c,v 1.8 2016/06/11 06:49:46 dholland Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -98,7 +98,7 @@ main(void)
 	for (;;) {
 		if (prom_boothow & RB_ASKNAME) {
 			printf("tapeboot: segment? [%s]: ", defname);
-			gets(line);
+			kgets(line, sizeof(line));
 			if (line[0])
 				file = line;
 			else

Reply via email to