After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 593232 - g_rand_new: read no more than requested from /dev/urandom
g_rand_new: read no more than requested from /dev/urandom
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 419150 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-08-26 21:42 UTC by Jonas Holmberg
Modified: 2009-09-08 19:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Turn off buffering on dev_urandom before freading it (247 bytes, patch)
2009-08-26 21:42 UTC, Jonas Holmberg
none Details | Review
Turn off buffering on dev_urandom before freading it (242 bytes, patch)
2009-08-27 08:39 UTC, Jonas Holmberg
none Details | Review

Description Jonas Holmberg 2009-08-26 21:42:32 UTC
Created attachment 141801 [details] [review]
Turn off buffering on dev_urandom before freading it

The call to fread() in g_rand_new() will result in 4096 bytes being read from
/dev/urandom, although only 16 of those bytes will be used. Turning off
buffering with setvbuf(3) before the call to fread() makes it read no more than
requested. This improves performance a lot and saves entropy.
Comment 1 Jonas Holmberg 2009-08-27 08:39:47 UTC
Created attachment 141832 [details] [review]
Turn off buffering on dev_urandom before freading it

No need for a size when turning buffering off.
Comment 2 Tim-Philipp Müller 2009-08-27 09:25:13 UTC
Performance issue, so adding 'perf' keyword. Duplicate of bug #419150 really, albeit with slightly different emphasis.
Comment 3 Tim-Philipp Müller 2009-09-08 19:44:21 UTC
*** Bug 419150 has been marked as a duplicate of this bug. ***