summaryrefslogtreecommitdiffstats
path: root/misc-utils/uuidd.c
diff options
context:
space:
mode:
authorPetr Uzel2012-05-03 21:02:01 +0200
committerKarel Zak2012-05-04 15:14:24 +0200
commit6126f7a53c57485a9a29ddd772765695f23c92e6 (patch)
treeb4f93a19a5459e69a7fa43b773590f42eb927b43 /misc-utils/uuidd.c
parentuuidd: introduce uuidd_cxt to pass arguments to server loop (diff)
downloadkernel-qcow2-util-linux-6126f7a53c57485a9a29ddd772765695f23c92e6.tar.gz
kernel-qcow2-util-linux-6126f7a53c57485a9a29ddd772765695f23c92e6.tar.xz
kernel-qcow2-util-linux-6126f7a53c57485a9a29ddd772765695f23c92e6.zip
libuuid: avoid double open and leaking descriptor
We are opening /dev/urandom twice in uuid_generate(): first to check if the file is available and then later __uuid_generate_random() again to actually get the random data. Moreover, descriptor from the first open is leaking. Fix by passign the descriptor down the stack and reusing it there. References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2 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 d20526e42..d3ed3eb7b 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);
+ __uuid_generate_random(uu, &num, -1);
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);
+ sizeof(num), &num, -1);
if (uuidd_cxt->debug) {
fprintf(stderr, P_("Generated %d UUID:\n",
"Generated %d UUIDs:\n", num), num);