]> granicus.if.org Git - python/commitdiff
bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922)
authorCtrlZvi <viz+github@flippedperspective.com>
Sun, 20 May 2018 15:03:25 +0000 (08:03 -0700)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 20 May 2018 15:03:25 +0000 (18:03 +0300)
uuid._ipconfig_getnode did not validate the maximum length of the value,
so long as the value had the same type of formatting as a MAC address.
This let it select DUIDs as MAC addresses. It now requires an exact
length match.

Lib/uuid.py
Misc/ACKS
Misc/NEWS.d/next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst [new file with mode: 0644]

index 9cb73e87718122c3a4cd7ee38d1e21e2de996177..66383218e70c0d52c8d7862abe6cdd7106f82f2c 100644 (file)
@@ -488,7 +488,7 @@ def _ipconfig_getnode():
         with proc:
             for line in proc.stdout:
                 value = line.split(':')[-1].strip().lower()
-                if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
+                if re.fullmatch('(?:[0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
                     mac = int(value.replace('-', ''), 16)
                     if _is_universal(mac):
                         return mac
index b1f1e8a4b8de31418d16cac2c34da455a24c45c9..cb7f4cd0275bc8c447f464c91b7eea1dc6b3fe1f 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -428,6 +428,7 @@ Ulrich Eckhardt
 David Edelsohn
 John Edmonds
 Grant Edwards
+Zvi Effron
 John Ehresman
 Tal Einat
 Eric Eisner
diff --git a/Misc/NEWS.d/next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst b/Misc/NEWS.d/next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst
new file mode 100644 (file)
index 0000000..16ba799
--- /dev/null
@@ -0,0 +1,2 @@
+Prevent ``uuid.get_node`` from using a DUID instead of a MAC on Windows.
+Patch by Zvi Effron