Skip to content

Commit 073eca3

Browse files
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 c66c342) Co-authored-by: CtrlZvi <[email protected]>
1 parent 736e3b3 commit 073eca3

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

‎Lib/uuid.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def _ipconfig_getnode():
488488
with proc:
489489
for line in proc.stdout:
490490
value = line.split(':')[-1].strip().lower()
491-
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
491+
if re.fullmatch('(?:[0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
492492
mac = int(value.replace('-', ''), 16)
493493
if _is_universal(mac):
494494
return mac

‎Misc/ACKS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ Ulrich Eckhardt
426426
David Edelsohn
427427
John Edmonds
428428
Grant Edwards
429+
Zvi Effron
429430
John Ehresman
430431
Tal Einat
431432
Eric Eisner
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Prevent ``uuid.get_node`` from using a DUID instead of a MAC on Windows.
2+
Patch by Zvi Effron

0 commit comments

Comments
 (0)