Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] Return correct value for uuid_generate_time_safe
@ 2015-06-17 15:59 Romain Bouvier
  2015-06-18 10:22 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Romain Bouvier @ 2015-06-17 15:59 UTC (permalink / raw)
  To: util-linux

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Return correct value for uuid_generate_time_safe
  2015-06-17 15:59 [PATCH] Return correct value for uuid_generate_time_safe Romain Bouvier
@ 2015-06-18 10:22 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-06-18 10:22 UTC (permalink / raw)
  To: Romain Bouvier; +Cc: util-linux

On Wed, Jun 17, 2015 at 03:59:18PM +0000, Romain Bouvier wrote:
> 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(+)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-18 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-17 15:59 [PATCH] Return correct value for uuid_generate_time_safe Romain Bouvier
2015-06-18 10:22 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox