From 38782bb4a3dfaf56369923576c85b2227ebcae77 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 26 Jun 2008 14:38:39 +0000 Subject: [PATCH] Fix incompatibility with non-recent mingw runtimes. --- trunk/gpgme/ChangeLog | 6 ++++++ trunk/gpgme/w32-util.c | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 2587f16..cdda77c 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2008-06-26 Werner Koch + + * w32-util.c (_gpgme_mkstemp): Replace sprint by stpcpy. + (mkstemp): Need to use GetSystemTimeAsFileTime for better + compatibility. + 2008-06-25 Marcus Brinkmann * gpgme-w32spawn.c: New file. diff --git a/trunk/gpgme/w32-util.c b/trunk/gpgme/w32-util.c index fc8e4be..05a9069 100644 --- a/trunk/gpgme/w32-util.c +++ b/trunk/gpgme/w32-util.c @@ -470,9 +470,11 @@ mkstemp (char *tmpl) /* Get some more or less random data. */ { - struct timeval tv; - gettimeofday (&tv, NULL); - random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; + FILETIME ft; + + GetSystemTimeAsFileTime (&ft); + random_time_bits = (((uint64_t)ft.dwHighDateTime << 32) + | (uint64_t)ft.dwLowDateTime); } value += random_time_bits ^ getpid (); @@ -537,7 +539,7 @@ _gpgme_mkstemp (int *fd, char **name) tmpname = malloc (strlen (tmp) + 13 + 1); if (!tmpname) return -1; - sprintf (tmpname, "%s\\gpgme-XXXXXX", tmp); + strcpy (stpcpy (tmpname, tmp), "\\gpgme-XXXXXX"); *fd = mkstemp (tmpname); if (fd < 0) return -1; -- 2.26.2