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 c66c342cb4)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
This commit is contained in:
Miss Islington (bot) 2018-05-20 08:40:10 -07:00 committed by GitHub
parent 736e3b3219
commit 073eca39a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View 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

View File

@ -426,6 +426,7 @@ Ulrich Eckhardt
David Edelsohn
John Edmonds
Grant Edwards
Zvi Effron
John Ehresman
Tal Einat
Eric Eisner

View File

@ -0,0 +1,2 @@
Prevent ``uuid.get_node`` from using a DUID instead of a MAC on Windows.
Patch by Zvi Effron