summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-17 14:51:42 (GMT)
committerGitHub <noreply@github.com>2020-03-17 14:51:42 (GMT)
commiteb886db1e99a15f15a2342aa496197a5f88fa9c8 (patch)
treec08db3a179900c44054a09986cccc10e92ccdb57 /Lib/uuid.py
parenta45b695b9fcfbbb0a087222abc5c8d691a7d2770 (diff)
downloadcpython-eb886db1e99a15f15a2342aa496197a5f88fa9c8.zip
cpython-eb886db1e99a15f15a2342aa496197a5f88fa9c8.tar.gz
cpython-eb886db1e99a15f15a2342aa496197a5f88fa9c8.tar.bz2
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.
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r--Lib/uuid.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index 224a766..3b3abc2 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -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.