mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:57:24 +00:00
UI: Net/Ip4Range: Fix PVS-Studio warning.
V610 Undefined behavior. Check the shift operator '<<'. The right operand ('(32 - nbits)' = [1..32]) is greater than or equal to the length in bits of the promoted left operand. ip4range.cpp 152
This commit is contained in:
parent
cf2ed5ad8f
commit
a05ee35f68
@ -41,6 +41,9 @@ TEST_F(NetUtilTest, ip4Ranges)
|
||||
ASSERT_TRUE(ip4Range.fromText("172.16.0.1/32"));
|
||||
ASSERT_EQ(ip4Range.toText(), QString("172.16.0.1\n"));
|
||||
|
||||
ASSERT_TRUE(ip4Range.fromText("172.16.0.1/0"));
|
||||
ASSERT_EQ(ip4Range.toText(), QString("172.16.0.1-255.255.255.255\n"));
|
||||
|
||||
// Simple range
|
||||
{
|
||||
ASSERT_TRUE(ip4Range.fromText("127.0.0.1\n"
|
||||
|
@ -149,7 +149,7 @@ bool Ip4Range::parseAddressMask(const StringView line, quint32 &from, quint32 &t
|
||||
return false;
|
||||
}
|
||||
|
||||
to = from | (nbits == 32 ? 0 : ((1 << (32 - nbits)) - 1));
|
||||
to = nbits == 0 ? quint32(-1) : (from | (nbits == 32 ? 0 : ((1 << (32 - nbits)) - 1)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user