1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 20:51:30 +00:00

Avoid undefined behavior of shifting over the sign bit by declaring unsigned literal

This commit is contained in:
dmiller
2016-07-28 05:11:34 +00:00
parent 4486148760
commit 2e05009ff7

View File

@@ -242,10 +242,10 @@ static void in_addr_to_octets(const struct in_addr *ia, uint8_t octets[4])
{ {
u32 hbo = ntohl(ia->s_addr); u32 hbo = ntohl(ia->s_addr);
octets[0] = (uint8_t) ((hbo & (0xFF << 24)) >> 24); octets[0] = (uint8_t) ((hbo & (0xFFU << 24)) >> 24);
octets[1] = (uint8_t) ((hbo & (0xFF << 16)) >> 16); octets[1] = (uint8_t) ((hbo & (0xFFU << 16)) >> 16);
octets[2] = (uint8_t) ((hbo & (0xFF << 8)) >> 8); octets[2] = (uint8_t) ((hbo & (0xFFU << 8)) >> 8);
octets[3] = (uint8_t) (hbo & 0xFF); octets[3] = (uint8_t) (hbo & 0xFFU);
} }
#define BITVECTOR_BITS (sizeof(bitvector_t) * CHAR_BIT) #define BITVECTOR_BITS (sizeof(bitvector_t) * CHAR_BIT)