Skip to content

Commit ea9a099

Browse files
[2.7] bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922) (GH-7015)
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 d13169f commit ea9a099

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
@@ -419,7 +419,7 @@ def _ipconfig_getnode():
419419
with pipe:
420420
for line in pipe:
421421
value = line.split(':')[-1].strip().lower()
422-
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
422+
if re.match('(?:[0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]$', value):
423423
return int(value.replace('-', ''), 16)
424424

425425
def _netbios_getnode():

‎Misc/ACKS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ Ulrich Eckhardt
381381
David Edelsohn
382382
John Edmonds
383383
Grant Edwards
384+
Zvi Effron
384385
John Ehresman
385386
Tal Einat
386387
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)