Fix incompatibility with non-recent mingw runtimes.

This commit is contained in:
Werner Koch 2008-06-26 14:38:39 +00:00
parent 0560f3089b
commit eccdb17c30
2 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2008-06-26 Werner Koch <wk@g10code.com>
* w32-util.c (_gpgme_mkstemp): Replace sprint by stpcpy.
(mkstemp): Need to use GetSystemTimeAsFileTime for better
compatibility.
2008-06-25 Marcus Brinkmann <marcus@g10code.de> 2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file. * gpgme-w32spawn.c: New file.

View File

@ -470,9 +470,11 @@ mkstemp (char *tmpl)
/* Get some more or less random data. */ /* Get some more or less random data. */
{ {
struct timeval tv; FILETIME ft;
gettimeofday (&tv, NULL);
random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; GetSystemTimeAsFileTime (&ft);
random_time_bits = (((uint64_t)ft.dwHighDateTime << 32)
| (uint64_t)ft.dwLowDateTime);
} }
value += random_time_bits ^ getpid (); value += random_time_bits ^ getpid ();
@ -537,7 +539,7 @@ _gpgme_mkstemp (int *fd, char **name)
tmpname = malloc (strlen (tmp) + 13 + 1); tmpname = malloc (strlen (tmp) + 13 + 1);
if (!tmpname) if (!tmpname)
return -1; return -1;
sprintf (tmpname, "%s\\gpgme-XXXXXX", tmp); strcpy (stpcpy (tmpname, tmp), "\\gpgme-XXXXXX");
*fd = mkstemp (tmpname); *fd = mkstemp (tmpname);
if (fd < 0) if (fd < 0)
return -1; return -1;