From: Remi Gacogne Date: Wed, 12 Jul 2023 08:49:31 +0000 (+0200) Subject: calidns: Fix setting an ECS source of 0 X-Git-Tag: rec-5.0.0-alpha1~79^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba770e4f65aefdadc489a169ae66fd20c897162c;p=thirdparty%2Fpdns.git calidns: Fix setting an ECS source of 0 --- diff --git a/pdns/calidns.cc b/pdns/calidns.cc index 87bfbe57ed..9afdbe93af 100644 --- a/pdns/calidns.cc +++ b/pdns/calidns.cc @@ -121,7 +121,7 @@ static ComboAddress getRandomAddressFromRange(const Netmask& ecsRange) { ComboAddress result = ecsRange.getMaskedNetwork(); uint8_t bits = ecsRange.getBits(); - uint32_t mod = 1 << (32 - bits); + uint32_t mod = (bits > 0) ? (1 << (32 - bits)) : std::numeric_limits::max(); result.sin4.sin_addr.s_addr = result.sin4.sin_addr.s_addr + ntohl(dns_random(mod)); return result; }