From 702193a6cc55802235453edbddb933187890ea1d Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Tue, 16 Jun 2015 17:29:25 -0500 Subject: [PATCH] Make sure configure-vm mac doesn't start negative The original version of this code allowed for the possibility of generating macs with negative numbers (consider generating 100 macs, with a random start value of 0xaa). While this is unlikely to be a problem in real-world uses of this code, it's still a potential bug if someone starts to push on the limits of what is supported. Change-Id: Ia42da0ece5ab3fbeccd6b4d8a4125c1bf5a658d0 --- scripts/configure-vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/configure-vm b/scripts/configure-vm index b06f0839..362d9297 100755 --- a/scripts/configure-vm +++ b/scripts/configure-vm @@ -43,7 +43,7 @@ def generate_baremetal_macs(count=1): start = random.randint(0x00, 0xff) if (start + (count * 2)) > 0xff: # leave room to generate macs in sequence - start -= (count * 2) + start = 0xff - count * 2 for num in range(0, count*2, 2): mac = start + num macs.append(base_mac + ":" + ("%02x" % mac))