Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sun68k/stand PR 51200 gets in libsa considered harm...



details:   https://anonhg.NetBSD.org/src/rev/31c41fcfd515
branches:  trunk
changeset: 345855:31c41fcfd515
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Jun 11 06:49:46 2016 +0000

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

diffstat:

 sys/arch/sun68k/stand/libsa/gets.c    |  9 +++++++--
 sys/arch/sun68k/stand/libsa/xxboot.c  |  4 ++--
 sys/arch/sun68k/stand/tapeboot/boot.c |  4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diffs (66 lines):

diff -r 81c058eaf92f -r 31c41fcfd515 sys/arch/sun68k/stand/libsa/gets.c
--- a/sys/arch/sun68k/stand/libsa/gets.c        Sat Jun 11 06:38:50 2016 +0000
+++ b/sys/arch/sun68k/stand/libsa/gets.c        Sat Jun 11 06:49:46 2016 +0000
@@ -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 @@
        lp = buf;
 
        for (;;) {
+               if (lp - buf == size) {
+                       lp--;
+                       *lp = '\0';
+                       return;
+               }
                c = getchar() & 0177;
 
 #ifdef GETS_MUST_ECHO  /* Preserved in case someone wants it... */
diff -r 81c058eaf92f -r 31c41fcfd515 sys/arch/sun68k/stand/libsa/xxboot.c
--- a/sys/arch/sun68k/stand/libsa/xxboot.c      Sat Jun 11 06:38:50 2016 +0000
+++ b/sys/arch/sun68k/stand/libsa/xxboot.c      Sat Jun 11 06:49:46 2016 +0000
@@ -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 @@
        just_ask:
                file = kernelnames[0];
                printf("filename? [%s]: ", file);
-               gets(line);
+               kgets(line, sizeof(line));
                if (line[0])
                        file = line;
 
diff -r 81c058eaf92f -r 31c41fcfd515 sys/arch/sun68k/stand/tapeboot/boot.c
--- a/sys/arch/sun68k/stand/tapeboot/boot.c     Sat Jun 11 06:38:50 2016 +0000
+++ b/sys/arch/sun68k/stand/tapeboot/boot.c     Sat Jun 11 06:49:46 2016 +0000
@@ -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 @@
        for (;;) {
                if (prom_boothow & RB_ASKNAME) {
                        printf("tapeboot: segment? [%s]: ", defname);
-                       gets(line);
+                       kgets(line, sizeof(line));
                        if (line[0])
                                file = line;
                        else



Home | Main Index | Thread Index | Old Index