mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Pull in some more bits from /dev/urandom periodically.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3628 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -372,9 +372,12 @@ guid_init_only_salt(const void *salt, size_t salt_len)
|
|||||||
guid_initialized = TRUE;
|
guid_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GUID_PERIOD 5000
|
||||||
|
|
||||||
void
|
void
|
||||||
guid_new(GUID *guid)
|
guid_new(GUID *guid)
|
||||||
{
|
{
|
||||||
|
static int counter = 0;
|
||||||
struct md5_ctx ctx;
|
struct md5_ctx ctx;
|
||||||
|
|
||||||
if (guid == NULL)
|
if (guid == NULL)
|
||||||
@@ -389,6 +392,23 @@ guid_new(GUID *guid)
|
|||||||
|
|
||||||
/* update the global context */
|
/* update the global context */
|
||||||
init_from_time();
|
init_from_time();
|
||||||
|
|
||||||
|
if (counter == 0)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = fopen ("/dev/urandom", "r");
|
||||||
|
if (fp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
init_from_stream(fp, 32);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
counter = GUID_PERIOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
counter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* needs 32 bytes exactly, doesn't print a null char */
|
/* needs 32 bytes exactly, doesn't print a null char */
|
||||||
|
|||||||
Reference in New Issue
Block a user