From: "Romain Bouvier" <skunnyk@alteroot.org>
To: util-linux@vger.kernel.org
Subject: [PATCH] Return correct value for uuid_generate_time_safe
Date: Wed, 17 Jun 2015 15:59:18 +0000 [thread overview]
Message-ID: <361341ee5502b6112bc452c27c15ea9f@webmail.alteroot.org> (raw)
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>
---
libuuid/src/gen_uuid.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index eb79339..2c5b955 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);
--
2.4.3
next reply other threads:[~2015-06-17 16:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 15:59 Romain Bouvier [this message]
2015-06-18 10:22 ` [PATCH] Return correct value for uuid_generate_time_safe Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=361341ee5502b6112bc452c27c15ea9f@webmail.alteroot.org \
--to=skunnyk@alteroot.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox