summaryrefslogtreecommitdiffstats
path: root/misc-utils/uuidd.c
diff options
context:
space:
mode:
authorPetr Uzel2012-05-06 21:55:53 +0200
committerKarel Zak2012-05-10 11:43:49 +0200
commitc544aa2c25095e6a4d4fca761eb15c46435086fc (patch)
treec188e1c320037328b009cf9cb6fa252fdeb1a2ad /misc-utils/uuidd.c
parentlslocks: fix bracket indentation (diff)
downloadkernel-qcow2-util-linux-c544aa2c25095e6a4d4fca761eb15c46435086fc.tar.gz
kernel-qcow2-util-linux-c544aa2c25095e6a4d4fca761eb15c46435086fc.tar.xz
kernel-qcow2-util-linux-c544aa2c25095e6a4d4fca761eb15c46435086fc.zip
libuuid: avoid double open and leaking fd (reworked)
This reverts commit 6126f7a53c57485a9a29ddd772765695f23c92e6 and fixes the double open and leaking descriptor in a different way, that is by using newly introduced function 'have_random_source()' to check whether good random source is available while deciding which uuid type to generate (random/time). This is better than calling random_get_fd() twice, passing the file descriptor down the stack and reusing it in next call to random_get_fd(). Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Diffstat (limited to 'misc-utils/uuidd.c')
-rw-r--r--misc-utils/uuidd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 768fed546..eb1ef02c6 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -442,7 +442,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- __uuid_generate_random(uu, &num, -1);
+ __uuid_generate_random(uu, &num);
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated random UUID: %s\n"), str);
@@ -473,7 +473,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
if (num * UUID_LEN > (int) (sizeof(reply_buf) - sizeof(num)))
num = (sizeof(reply_buf) - sizeof(num)) / UUID_LEN;
__uuid_generate_random((unsigned char *) reply_buf +
- sizeof(num), &num, -1);
+ sizeof(num), &num);
if (uuidd_cxt->debug) {
fprintf(stderr, P_("Generated %d UUID:\n",
"Generated %d UUIDs:\n", num), num);