diff options
author | Pali Rohár <pali@kernel.org> | 2024-01-20 12:30:08 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-02-18 16:18:43 +0100 |
commit | 155f087b19681f043cd65283559a7a8dea08c85a (patch) | |
tree | f6585031d0b9fc8ab5989e2438e2a91df0508ff9 | |
parent | 7d347ab73a39d37bb3134b8a1c7970030a19e009 (diff) | |
download | pciutils-155f087b19681f043cd65283559a7a8dea08c85a.tar.gz |
libpci: physmem-posix: Fix OFF_MAX definition
Expression ((1 << n) - 1) for n=31 has undefined behavior and gcc 11
already evaluates it to zero.
Fix definition of OFF_MAX to prevent signed integer overflow.
-rw-r--r-- | lib/physmem-posix.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/physmem-posix.c b/lib/physmem-posix.c index 664ec48..7cd7e99 100644 --- a/lib/physmem-posix.c +++ b/lib/physmem-posix.c @@ -26,7 +26,7 @@ #include <unistd.h> #ifndef OFF_MAX -#define OFF_MAX (off_t)((1ULL << (sizeof(off_t) * CHAR_BIT - 1)) - 1) +#define OFF_MAX ((((off_t)1 << (sizeof(off_t) * CHAR_BIT - 2)) - 1) * 2 + 1) #endif struct physmem { |