Skip to contentSkip to conversation

Return correct value for uuid_generate_time_safe

PATCH Applied Romain Bouvier 2 participants 2 messages Jun 17, 2015 – Jun 18, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 libuuid/src/gen_uuid.c | 3 +++
 1 file changed, 3 insertions(+)
libuuid/src/gen_uuid.c +3 -0
index eb79339..2c5b955 100644
@@ -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);
Signature · 1 line
2.4.3
maintainer Applied
#1 lore raw
Quoted 6 lines · Romain Bouvier

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.

Quoted 6 lines
---
 libuuid/src/gen_uuid.c | 3 +++
 1 file changed, 3 insertions(+)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com