Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs Avoid unportable shift base -1 in ffs_subr.c
details: https://anonhg.NetBSD.org/src/rev/3ac2eb72c4e6
branches: trunk
changeset: 999295:3ac2eb72c4e6
user: kamil <kamil%NetBSD.org@localhost>
date: Tue May 28 03:53:28 2019 +0000
description:
Avoid unportable shift base -1 in ffs_subr.c
Cast the start variable before the modulo opration to unsigned int.
Detected with kUBSan.
diffstat:
sys/ufs/ffs/ffs_subr.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (36 lines):
diff -r 730e9b5f11c6 -r 3ac2eb72c4e6 sys/ufs/ffs/ffs_subr.c
--- a/sys/ufs/ffs/ffs_subr.c Tue May 28 03:52:08 2019 +0000
+++ b/sys/ufs/ffs/ffs_subr.c Tue May 28 03:53:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $ */
+/* $NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -36,7 +36,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $");
#include <sys/param.h>
@@ -313,7 +313,7 @@
end = ufs_rw32(cgp->cg_nclusterblks, needswap);
mapp = &freemapp[start / NBBY];
map = *mapp++;
- bit = 1U << (start % NBBY);
+ bit = 1U << ((unsigned int)start % NBBY);
for (i = start; i < end; i++) {
if ((map & bit) == 0)
break;
@@ -334,7 +334,7 @@
end = -1;
mapp = &freemapp[start / NBBY];
map = *mapp--;
- bit = 1U << (start % NBBY);
+ bit = 1U << ((unsigned int)start % NBBY);
for (i = start; i > end; i--) {
if ((map & bit) == 0)
break;
Home |
Main Index |
Thread Index |
Old Index