Skip to content

Commit 6df1d1c

Browse files
committed
Fix some UBSAN issues:
*) common.c:2041:13: runtime error: left shift of 1 by 31 places cannot be represented in type 'long' *) inet_util.c:847:36: runtime error: left shift of negative value -1
1 parent 1306ae1 commit 6df1d1c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ int fnmatch (const char *pattern, const char *string, int flags)
20032003
* "C Programmer's Guide to Serial Communications", by Joe Campbell.
20042004
*/
20052005
#define CRC_BITS 32
2006-
#define CRC_HIBIT ((DWORD) (1L << (CRC_BITS-1)))
2006+
#define CRC_HIBIT ((DWORD) (1UL << (CRC_BITS-1)))
20072007
#define CRC_SHIFTS (CRC_BITS-8)
20082008

20092009
/* Our PRZ's 24-bit CRC generator polynomial. Ref:

src/inet_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ int INET_util_network_len128 (const struct in6_addr *a, const struct in6_addr *b
843843
*/
844844
void INET_util_get_mask4 (struct in_addr *out, int bits)
845845
{
846-
*(DWORD*)out = bits ? swap32 (~0 << (32 - bits)) : 0;
846+
*(DWORD*)out = bits ? swap32 (~0UL << (DWORD)(32 - bits)) : 0;
847847
}
848848

849849
/**

0 commit comments

Comments
 (0)