Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fix clrbits() so that it doesn't mask no bits out o...



details:   https://anonhg.NetBSD.org/src/rev/6d2fd0bd6d75
branches:  trunk
changeset: 749018:6d2fd0bd6d75
user:      dsl <dsl%NetBSD.org@localhost>
date:      Fri Nov 13 19:15:24 2009 +0000

description:
Fix clrbits() so that it doesn't mask no bits out of the byte after the
range (when the last bit to be cleared is the msb of a byte).
Fixes PR/42312 in a slightly better way than proposed.

diffstat:

 sys/kern/tty_subr.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r e94731930712 -r 6d2fd0bd6d75 sys/kern/tty_subr.c
--- a/sys/kern/tty_subr.c       Fri Nov 13 19:00:15 2009 +0000
+++ b/sys/kern/tty_subr.c       Fri Nov 13 19:15:24 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_subr.c,v 1.37 2009/11/13 19:00:15 dsl Exp $        */
+/*     $NetBSD: tty_subr.c,v 1.38 2009/11/13 19:15:24 dsl Exp $        */
 
 /*
  * Copyright (c) 1993, 1994 Theo de Raadt
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.37 2009/11/13 19:00:15 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.38 2009/11/13 19:15:24 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -312,10 +312,11 @@
                return;
        }
 
+       len--;
        sby = off / NBBY;
        sbi = off % NBBY;
        eby = (off+len) / NBBY;
-       ebi = (off+len) % NBBY;
+       ebi = (off+len) % NBBY + 1;
        if (sby == eby) {
                mask = ((1 << (ebi - sbi)) - 1) << sbi;
                cp[sby] &= ~mask;



Home | Main Index | Thread Index | Old Index