bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)

uuid.getnode() now skips IPv6 addresses with the same string length
than a MAC address (17 characters): only use MAC addresses.
This commit is contained in:
Victor Stinner 2020-03-17 15:51:42 +01:00 committed by GitHub
parent a45b695b9f
commit eb886db1e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 10 deletions

View file

@ -456,7 +456,10 @@ def _find_mac_under_heading(command, args, heading):
try:
words = line.rstrip().split()
word = words[column_index]
if len(word) == 17:
# Accept 'HH:HH:HH:HH:HH:HH' MAC address (ex: '52:54:00:9d:0e:67'),
# but reject IPv6 address (ex: 'fe80::5054:ff:fe9') detected
# by '::' pattern.
if len(word) == 17 and b'::' not in word:
mac = int(word.replace(_MAC_DELIM, b''), 16)
elif _MAC_OMITS_LEADING_ZEROES:
# (Only) on AIX the macaddr value given is not prefixed by 0, e.g.