Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Andrew Brown found that we overflowed all cases in ...



details:   https://anonhg.NetBSD.org/src/rev/70c6719ddc22
branches:  trunk
changeset: 521933:70c6719ddc22
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Feb 08 18:36:53 2002 +0000

description:
Andrew Brown found that we overflowed all cases in the TTLINEDNAMELEN.
ouch.

diffstat:

 sys/kern/tty.c      |  10 +++++-----
 sys/kern/tty_conf.c |   6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diffs (65 lines):

diff -r fb2e05ec0a02 -r 70c6719ddc22 sys/kern/tty.c
--- a/sys/kern/tty.c    Fri Feb 08 18:35:30 2002 +0000
+++ b/sys/kern/tty.c    Fri Feb 08 18:36:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.130 2002/01/28 02:06:03 simonb Exp $ */
+/*     $NetBSD: tty.c,v 1.131 2002/02/08 18:36:53 christos Exp $       */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.130 2002/01/28 02:06:03 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.131 2002/02/08 18:36:53 christos Exp $");
 
 #include "opt_uconsole.h"
 
@@ -829,8 +829,8 @@
                *(int *)data = tp->t_linesw->l_no;
                break;
        case TIOCGLINED:
-               strncpy((char *)data, tp->t_linesw->l_name, 
-                       TTLINEDNAMELEN);
+               (void)strncpy((char *)data, tp->t_linesw->l_name, 
+                   TTLINEDNAMELEN - 1);
                break;
        case TIOCGWINSZ:                /* get window size */
                *(struct winsize *)data = tp->t_winsize;
@@ -936,7 +936,7 @@
                dev_t device;
 
                /* Null terminate to prevent buffer overflow */
-               name[TTLINEDNAMELEN] = 0; 
+               name[TTLINEDNAMELEN - 1] = '\0'; 
                lp = ttyldisc_lookup(name);
 
  setldisc:
diff -r fb2e05ec0a02 -r 70c6719ddc22 sys/kern/tty_conf.c
--- a/sys/kern/tty_conf.c       Fri Feb 08 18:35:30 2002 +0000
+++ b/sys/kern/tty_conf.c       Fri Feb 08 18:36:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_conf.c,v 1.36 2001/12/03 23:30:37 augustss Exp $   */
+/*     $NetBSD: tty_conf.c,v 1.37 2002/02/08 18:36:53 christos Exp $   */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.36 2001/12/03 23:30:37 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.37 2002/02/08 18:36:53 christos Exp $");
 
 #include "opt_compat_freebsd.h"
 #include "opt_compat_43.h"
@@ -194,7 +194,7 @@
 {
 
        /* You are not allowed to exceed TTLINEDNAMELEN */
-       if (strlen(disc->l_name) > TTLINEDNAMELEN)
+       if (strlen(disc->l_name) >= TTLINEDNAMELEN)
                return (-1);
 
        /* 



Home | Main Index | Thread Index | Old Index