Skip to content

Commit e9e2fd7

Browse files
[3.6] bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922) (GH-7014)
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 7208bfb commit e9e2fd7

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
@@ -438,7 +438,7 @@ def _ipconfig_getnode():
438438
with proc:
439439
for line in proc.stdout:
440440
value = line.split(':')[-1].strip().lower()
441-
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
441+
if re.fullmatch('(?:[0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
442442
return int(value.replace('-', ''), 16)
443443

444444
def _netbios_getnode():

‎Misc/ACKS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ Ulrich Eckhardt
415415
David Edelsohn
416416
John Edmonds
417417
Grant Edwards
418+
Zvi Effron
418419
John Ehresman
419420
Tal Einat
420421
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)