Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Avoid unportable signed integer left shift in fd_un...
details: https://anonhg.NetBSD.org/src/rev/e952290a6a45
branches: trunk
changeset: 362969:e952290a6a45
user: kamil <kamil%NetBSD.org@localhost>
date: Tue Jul 03 23:14:57 2018 +0000
description:
Avoid unportable signed integer left shift in fd_unused()
Detected with Kernel Undefined Behavior Sanitizer.
There were at least a single place reported, for consistency fix all the
left bit shift operations.
sys/kern/kern_descrip.c:345:2, left shift of 1 by 31 places cannot be represented in type 'int'
sys/kern/kern_descrip.c:346:28, left shift of 1 by 31 places cannot be represented in type 'int'
Reported by <Harry Pantazis>
diffstat:
sys/kern/kern_descrip.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (35 lines):
diff -r 78c3af9469ee -r e952290a6a45 sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c Tue Jul 03 23:11:06 2018 +0000
+++ b/sys/kern/kern_descrip.c Tue Jul 03 23:14:57 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.234 2018/07/03 23:11:06 kamil Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.235 2018/07/03 23:14:57 kamil Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.234 2018/07/03 23:11:06 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.235 2018/07/03 23:14:57 kamil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -338,12 +338,12 @@
if (fdp->fd_lomap[off] == ~0) {
KASSERT((fdp->fd_himap[off >> NDENTRYSHIFT] &
- (1 << (off & NDENTRYMASK))) != 0);
+ (1U << (off & NDENTRYMASK))) != 0);
fdp->fd_himap[off >> NDENTRYSHIFT] &=
- ~(1 << (off & NDENTRYMASK));
+ ~(1U << (off & NDENTRYMASK));
}
- KASSERT((fdp->fd_lomap[off] & (1 << (fd & NDENTRYMASK))) != 0);
- fdp->fd_lomap[off] &= ~(1 << (fd & NDENTRYMASK));
+ KASSERT((fdp->fd_lomap[off] & (1U << (fd & NDENTRYMASK))) != 0);
+ fdp->fd_lomap[off] &= ~(1U << (fd & NDENTRYMASK));
ff->ff_allocated = false;
KASSERT(fd <= fdp->fd_lastfile);
Home |
Main Index |
Thread Index |
Old Index