diff options
| author | 2009-11-13 21:10:34 +0000 | |
|---|---|---|
| committer | 2009-11-13 21:10:34 +0000 | |
| commit | a19bfdbec64e75ed5b8e3189f00c4fcf3ff8443a (patch) | |
| tree | 3b5c1676d7b7c819fe4c09f7f4e4390005e40b18 /sys/kern/tty_subr.c | |
| parent | Extend the protosw pr_ctlinput function to include the rdomain. This is (diff) | |
| download | wireguard-openbsd-a19bfdbec64e75ed5b8e3189f00c4fcf3ff8443a.tar.xz wireguard-openbsd-a19bfdbec64e75ed5b8e3189f00c4fcf3ff8443a.zip | |
>15 year old buffer-read-1-byte-too-far in clrbits() [code I wrote, yeah]
with a subtle change to make it more clear (and more cache friendly)
netbsd pr 42312, found by tlambert@apple.com
ok miod
Diffstat (limited to 'sys/kern/tty_subr.c')
| -rw-r--r-- | sys/kern/tty_subr.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c index e14e5bef642..3518cbc1b37 100644 --- a/sys/kern/tty_subr.c +++ b/sys/kern/tty_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_subr.c,v 1.21 2009/07/19 08:16:06 blambert Exp $ */ +/* $OpenBSD: tty_subr.c,v 1.22 2009/11/13 21:10:34 deraadt Exp $ */ /* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */ /* @@ -304,11 +304,13 @@ clrbits(u_char *cp, int off, int len) mask = (1<<sbi) - 1; cp[sby++] &= mask; - mask = (1<<ebi) - 1; - cp[eby] &= ~mask; - for (i = sby; i < eby; i++) cp[i] = 0x00; + + mask = (1<<ebi) - 1; + if (mask) /* if no mask, eby may be 1 too far */ + cp[eby] &= ~mask; + } } |
