Fix UUID generation according to RFC 4122

In commit 74aa8c8a, I somehow made an off-by-one error even though
that code was almost copy-paste from libvirt's commit 396c4d34.
This commit is contained in:
Martin Kletzander 2013-08-16 10:02:56 +02:00
parent 8460af9a99
commit 64b1ca15f2

View File

@ -378,8 +378,8 @@ def randomUUID(conn):
return "00000000-1111-2222-3333-444444444444"
u = [random.randint(0, 255) for ignore in range(0, 16)]
u[7] = (u[7] & 0x0F) | (4 << 4)
u[9] = (u[9] & 0x3F) | (2 << 6)
u[6] = (u[6] & 0x0F) | (4 << 4)
u[8] = (u[8] & 0x3F) | (2 << 6)
return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2,
"%02x" * 6]) % tuple(u)