Skip to content

Commit

Permalink
Fix some UBSAN issues:
Browse files Browse the repository at this point in the history
  *) 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
  • Loading branch information
gvanem committed Jan 18, 2025
1 parent 1306ae1 commit 6df1d1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ int fnmatch (const char *pattern, const char *string, int flags)
* "C Programmer's Guide to Serial Communications", by Joe Campbell.
*/
#define CRC_BITS 32
#define CRC_HIBIT ((DWORD) (1L << (CRC_BITS-1)))
#define CRC_HIBIT ((DWORD) (1UL << (CRC_BITS-1)))
#define CRC_SHIFTS (CRC_BITS-8)

/* Our PRZ's 24-bit CRC generator polynomial. Ref:
Expand Down
2 changes: 1 addition & 1 deletion src/inet_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ int INET_util_network_len128 (const struct in6_addr *a, const struct in6_addr *b
*/
void INET_util_get_mask4 (struct in_addr *out, int bits)
{
*(DWORD*)out = bits ? swap32 (~0 << (32 - bits)) : 0;
*(DWORD*)out = bits ? swap32 (~0UL << (DWORD)(32 - bits)) : 0;
}

/**
Expand Down

0 comments on commit 6df1d1c

Please sign in to comment.