From: Jim Meyering <jim@meyering.net>
To: linux-ext4@vger.kernel.org
Subject: close /dev/urandom fd (e2fsprogs 1.40-WIP (7-Apr-2007))
Date: Fri, 15 Jun 2007 22:28:40 +0200 [thread overview]
Message-ID: <878xalc687.fsf@rho.meyering.net> (raw)
The file descriptor opened on /dev/urandom can be closed sooner:
diff -r 11b6e3e021f0 -r 777972a573b3 lib/uuid/ChangeLog
--- a/lib/uuid/ChangeLog Thu May 31 12:39:02 2007 -0400
+++ b/lib/uuid/ChangeLog Fri Jun 15 18:05:09 2007 +0200
@@ -1,3 +1,8 @@ 2006-10-22 Theodore Tso <tytso@mit.edu
+2007-06-15 Jim Meyering <jim@meyering.net>
+
+ * gen_uuid.c (get_random_bytes): Don't leave /dev/urandom open.
+ (uuid_generate): Likewise.
+
2006-10-22 Theodore Tso <tytso@mit.edu>
* gen_uuid.c (get_random_bytes): Add in randomness based on
diff -r 11b6e3e021f0 -r 777972a573b3 lib/uuid/gen_uuid.c
--- a/lib/uuid/gen_uuid.c Thu May 31 12:39:02 2007 -0400
+++ b/lib/uuid/gen_uuid.c Fri Jun 15 18:05:09 2007 +0200
@@ -139,6 +139,7 @@ static void get_random_bytes(void *buf,
cp += i;
lose_counter = 0;
}
+ close(fd);
}
/*
@@ -337,8 +338,10 @@ void uuid_generate_random(uuid_t out)
*/
void uuid_generate(uuid_t out)
{
- if (get_random_fd() >= 0)
+ int fd;
+ if ((fd = get_random_fd()) >= 0) {
+ close(fd);
uuid_generate_random(out);
- else
+ } else
uuid_generate_time(out);
}
Signed-off-by: Jim Meyering <jim@meyering.net>
next reply other threads:[~2007-06-15 20:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-15 20:28 Jim Meyering [this message]
2007-06-15 22:08 ` close /dev/urandom fd (e2fsprogs 1.40-WIP (7-Apr-2007)) Theodore Tso
2007-06-16 5:38 ` Jim Meyering
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=878xalc687.fsf@rho.meyering.net \
--to=jim@meyering.net \
--cc=linux-ext4@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