]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922) (GH-7015)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 20 May 2018 22:50:33 +0000 (01:50 +0300)
committerGitHub <noreply@github.com>
Sun, 20 May 2018 22:50:33 +0000 (01:50 +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..
(cherry picked from commit c66c342cb42ab8a88884527ddfe3a5086bc06316)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
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 618bc6385cfcb9ead418bf4526e7237b7fae1db4..973013c00636c9a7bf54d93d817cc281835e7935 100644 (file)
@@ -419,7 +419,7 @@ def _ipconfig_getnode():
         with pipe:
             for line in pipe:
                 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.match('(?:[0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]$', value):
                     return int(value.replace('-', ''), 16)
 
 def _netbios_getnode():
index 394fbb93f2f184163bc2239f3d70be44461c96ff..295b933f4b95683948094f8556a9d2ad75eb132c 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -381,6 +381,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