]> git.proxmox.com Git - pve-common.git/commitdiff
fix mac address generation limitation
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 5 Jul 2016 10:40:23 +0000 (12:40 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 5 Jul 2016 11:42:30 +0000 (13:42 +0200)
Commit de9a267 introduced vec() to optimize the generation
by using binary operations instead of converting back and
forth between hex and strings, but forgot to switch over to
the binary sha1 method. This resulted in only the first 6
hex digits of the output string making up the address.

src/PVE/Tools.pm

index 68c4e68ba934370c4ec05aca5c6cfeee5ca0a516..0d03b047624e0d3c668ba3fbd2c5fa19cf571050 100644 (file)
@@ -983,7 +983,7 @@ sub random_ether_addr {
 
     my ($seconds, $microseconds) = gettimeofday;
 
-    my $rand = Digest::SHA::sha1_hex($$, rand(), $seconds, $microseconds);
+    my $rand = Digest::SHA::sha1($$, rand(), $seconds, $microseconds);
 
     # clear multicast, set local id
     vec($rand, 0, 8) = (vec($rand, 0, 8) & 0xfe) | 2;