summaryrefslogtreecommitdiff
path: root/dns/edns.py
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2019-05-03 08:17:54 -0700
committerBob Halley <halley@dnspython.org>2019-05-03 08:17:54 -0700
commitf5df40956ab8c380370b66363149908e2aaa1d6d (patch)
tree7ff2a65257533b7f0921af4850fc73e6f3e881a6 /dns/edns.py
parentaab95c61d554dcf8bc2cf991811165a320991b8c (diff)
downloaddnspython-f5df40956ab8c380370b66363149908e2aaa1d6d.tar.gz
The EDNS0 client-subnet code didn't work correctly for addresses that
were not a multiple of 8 bits. Instead of preserving the required number of high-order bits, it cleared that number of low-order bits. Thanks to Brian Wellington for discovering this and providing the correct code.
Diffstat (limited to 'dns/edns.py')
-rw-r--r--dns/edns.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/dns/edns.py b/dns/edns.py
index 5660f7b..57dd256 100644
--- a/dns/edns.py
+++ b/dns/edns.py
@@ -195,7 +195,8 @@ class ECSOption(Option):
self.addrdata = addrdata[:nbytes]
nbits = srclen % 8
if nbits != 0:
- last = struct.pack('B', ord(self.addrdata[-1:]) & (0xff << nbits))
+ last = struct.pack('B',
+ ord(self.addrdata[-1:]) & (0xff << (8 - nbits)))
self.addrdata = self.addrdata[:-1] + last
def to_text(self):