mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- Fixed bug whereby the UUID generated by the custom generator was not terminated.
- Fixed bug whereby random numbers were used by the custom UUID generator, but srandom/srand was not called first.
This commit is contained in:
parent
f3de5c0711
commit
08f4ead97e
5 changed files with 20 additions and 6 deletions
|
@ -182,14 +182,18 @@ const std::string uuid ()
|
|||
static char randomHexDigit ()
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
#ifdef HAVE_RANDOM
|
||||
return digits[random () % 16];
|
||||
#else
|
||||
return digits[rand () % 16];
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string uuid ()
|
||||
{
|
||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
char id [37];
|
||||
char id [48] = {0};
|
||||
id[0] = randomHexDigit ();
|
||||
id[1] = randomHexDigit ();
|
||||
id[2] = randomHexDigit ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue