libpcap/0611-With-MSVC-abort-if-_BitScanForward-returns-0.patch

32 lines
1021 B
Diff
Raw Normal View History

2020-08-07 16:11:04 +08:00
From 3b9b6100912f7bb1ee43f9cfb51e804765a37bd4 Mon Sep 17 00:00:00 2001
From: Guy Harris <guy@alum.mit.edu>
Date: Thu, 3 Oct 2019 09:27:36 -0700
Subject: [PATCH 611/977] With MSVC, abort if _BitScanForward() returns 0.
It should never return zero, as never pass a value of 0 to
lowest_set_bit(), but this should keep Coverity from getting upset (as a
result of not understanding _BitScanForward() well enough to realize
that if it's passed a non-zero value it will never return 0).
Reported by Charles Smith at Tangible Security.
---
optimize.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/optimize.c b/optimize.c
index 283a6de..e38d2d7 100644
--- a/optimize.c
+++ b/optimize.c
@@ -137,7 +137,7 @@ lowest_set_bit(int mask)
* (It's currently not, in MSVC, even on 64-bit platforms, but....)
*/
if (_BitScanForward(&bit, (unsigned int)mask) == 0)
- return -1; /* mask is zero */
+ abort(); /* mask is zero */
return (int)bit;
}
#elif defined(MSDOS) && defined(__DJGPP__)
--
1.8.3.1