Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Prevent signed integer left shift UB in FD_SET(), FD...
details: https://anonhg.NetBSD.org/src/rev/f8dbe4f12190
branches: trunk
changeset: 323645:f8dbe4f12190
user: kamil <kamil%NetBSD.org@localhost>
date: Sun Jun 24 12:05:40 2018 +0000
description:
Prevent signed integer left shift UB in FD_SET(), FD_CLR(), FD_ISSET()
Set the type of shifted integer 1 to unsigned int.
Detected with MKSANITIZER/UBSan in sysinst(8).
diffstat:
sys/sys/fd_set.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (24 lines):
diff -r 885cda268e4c -r f8dbe4f12190 sys/sys/fd_set.h
--- a/sys/sys/fd_set.h Sun Jun 24 11:51:15 2018 +0000
+++ b/sys/sys/fd_set.h Sun Jun 24 12:05:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fd_set.h,v 1.6 2015/11/06 15:41:25 christos Exp $ */
+/* $NetBSD: fd_set.h,v 1.7 2018/06/24 12:05:40 kamil Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -68,11 +68,11 @@
} fd_set;
#define FD_SET(n, p) \
- ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] |= (1 << ((n) & __NFDMASK)))
+ ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] |= (1U << ((n) & __NFDMASK)))
#define FD_CLR(n, p) \
- ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] &= ~(1 << ((n) & __NFDMASK)))
+ ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] &= ~(1U << ((n) & __NFDMASK)))
#define FD_ISSET(n, p) \
- ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] & (1 << ((n) & __NFDMASK)))
+ ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] & (1U << ((n) & __NFDMASK)))
#if __GNUC_PREREQ__(2, 95)
#define FD_ZERO(p) (void)__builtin_memset((p), 0, sizeof(*(p)))
#else
Home |
Main Index |
Thread Index |
Old Index