Fix incompatibility with non-recent mingw runtimes.
authorWerner Koch <wk@gnupg.org>
Thu, 26 Jun 2008 14:38:39 +0000 (14:38 +0000)
committerWerner Koch <wk@gnupg.org>
Thu, 26 Jun 2008 14:38:39 +0000 (14:38 +0000)
gpgme/ChangeLog
gpgme/w32-util.c

index 2587f16cb8182cb6f849ff2d4b349705c470d6bc..cdda77ca293ec55ae17e6ece5390d5f52edd74bf 100644 (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>
 
        * gpgme-w32spawn.c: New file.
index fc8e4be13c4108720b9c1cf6b21d059e0a8a3176..05a9069bc1e160b15d2d08d5883b0e3451c47752 100644 (file)
@@ -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;