From 073eca39a55b86ec7dd7a437ac0c910751a60ace Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 20 May 2018 08:40:10 -0700 Subject: [PATCH] bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922) 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 --- Lib/uuid.py | 2 +- Misc/ACKS | 1 + .../next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst diff --git a/Lib/uuid.py b/Lib/uuid.py index 9cb73e87718..66383218e70 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -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 diff --git a/Misc/ACKS b/Misc/ACKS index ffc932b0860..31ad80f8bc9 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -426,6 +426,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 index 00000000000..16ba799131f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-05-16-09-30-27.bpo-33542.idNAcs.rst @@ -0,0 +1,2 @@ +Prevent ``uuid.get_node`` from using a DUID instead of a MAC on Windows. +Patch by Zvi Effron