diff options
author | Romain Bouvier | 2015-06-17 17:59:18 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-18 12:12:16 +0200 |
commit | c893f5e462265b59cd0c27bd38b6355e799a302a (patch) | |
tree | bf80dbbf679510b1331d9c3d991d3ddfacd99c55 /libuuid | |
parent | libfdisk: ignore misaligned optimal I/O size (diff) | |
download | kernel-qcow2-util-linux-c893f5e462265b59cd0c27bd38b6355e799a302a.tar.gz kernel-qcow2-util-linux-c893f5e462265b59cd0c27bd38b6355e799a302a.tar.xz kernel-qcow2-util-linux-c893f5e462265b59cd0c27bd38b6355e799a302a.zip |
libuuid: return correct value for uuid_generate_time_safe
Make return value consistent for consecutive calls. If you call
uuid_generate_time_safe, it should always return -1 if it can't guarantee
uniqueness. Without this patch, on consecutive calls where it can't guarantee
uniqueness, the first call returns -1, but later calls return 0.
Reported-by: Romain Bouvier <skunnyk@alteroot.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Diffstat (limited to 'libuuid')
-rw-r--r-- | libuuid/src/gen_uuid.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index eb793391c..2c5b95564 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -227,6 +227,9 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, int len; int ret = 0; + if (state_fd == -1) + ret = -1; + if (state_fd == -2) { save_umask = umask(0); state_fd = open(LIBUUID_CLOCK_FILE, O_RDWR|O_CREAT|O_CLOEXEC, 0660); |