]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libuuid: fix name-based UUIDs
authorKarel Zak <kzak@redhat.com>
Fri, 31 Aug 2018 10:27:32 +0000 (12:27 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 31 Aug 2018 10:43:17 +0000 (12:43 +0200)
commitd6ddf07d31dfdc894eb8e7e6842aa856342c526e
treea498e9dfeac43c6e48716caad52a391e6b92dfbb
parent9a312758eeee7c3dc3edcece0d60b68daac8ff3b
libuuid: fix name-based UUIDs

The current version is not fully compatible with RFC4122. It
incorrectly encodes UUID variant

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

where M is UUID version and N is UUID variant.

 $ python -c "import uuid ; print(uuid.uuid5(uuid.UUID(int=0), 'foo'))"
 aa752cea-8222-5bc8-acd9-555b090c0ccb
                    ^^

Old version:

 $ uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1
 aa752cea-8222-5bc8-8cd9-555b090c0ccb
                    ^^

Fixed version:
 ./uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1;
 aa752cea-8222-5bc8-acd9-555b090c0ccb
                    ^^

The patch uses uuid_unpack and uuid_pack. It makes code more readable
and allow to access proper octens. The same way we already use for
time and random based UUIDs.

Addresses: https://github.com/karelzak/util-linux/issues/683
Signed-off-by: Karel Zak <kzak@redhat.com>
libuuid/src/gen_uuid.c