From 08f4ead97e7688cf06bce298260bcc8a824253a0 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 4 Jun 2008 21:00:23 -0400 Subject: [PATCH] - 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. --- AUTHORS | 7 ++++--- configure.ac | 4 +++- src/task.cpp | 7 +++++++ src/util.cpp | 6 +++++- task.html | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4f6a1697e..81e64a681 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,7 @@ -Principal Author +Principal Author: Paul Beckingham, paul@beckingham.net -Contributing Authors - +With thanks to: + Eugene Kramer + SK diff --git a/configure.ac b/configure.ac index d37590d47..85e8affb4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT(task, 1.0.0, bugs@beckingham.net) +AC_INIT(task, 1.0.1, bugs@beckingham.net) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/task.cpp]) AC_CONFIG_HEADER([auto.h]) @@ -35,6 +35,8 @@ AC_FUNC_SELECT_ARGTYPES AC_CHECK_FUNCS([select]) AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])]) AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])]) +AC_CHECK_FUNC(random, [AC_DEFINE([HAVE_RANDOM], [1], [Found random])]) +AC_CHECK_FUNC(srandom, [AC_DEFINE([HAVE_SRANDOM], [1], [Found srandom])]) AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT diff --git a/src/task.cpp b/src/task.cpp index b8f03aa87..8e453a932 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -207,6 +207,13 @@ int main (int argc, char** argv) // TODO Find out what this is, and either promote it to live code, or remove it. // std::set_terminate (__gnu_cxx::__verbose_terminate_handler); + // Set up randomness. +#ifdef HAVE_SRANDOM + srandom (time (NULL)); +#else + srand (time (NULL)); +#endif + try { // Load the config file from the home directory. If the file cannot be diff --git a/src/util.cpp b/src/util.cpp index 231192170..c4ec34e24 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 (); diff --git a/task.html b/task.html index 91b18f050..8de00c729 100644 --- a/task.html +++ b/task.html @@ -5,7 +5,7 @@ - Download latest task task-1.0.0.tar.gz (6/3/2008). + Download the latest task source code task-1.0.0.tar.gz (6/3/2008).