aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-11-18 10:23:09 +0000
committerNIIBE Yutaka <[email protected]>2022-11-18 10:23:09 +0000
commitce5bed2800e59d5866b60648ee6487e5fcb72012 (patch)
tree4b10e8b1cedd0a090a2d800d5a113a2e7d95f5f5
parentscd: Redact --debug cardio output of a VERIFY APDU. (diff)
downloadgnupg-ce5bed2800e59d5866b60648ee6487e5fcb72012.tar.gz
gnupg-ce5bed2800e59d5866b60648ee6487e5fcb72012.zip
w32: Fix gnupg_tmpfile for possible failure.
* common/sysutils.c (gnupg_tmpfile): Use different value for next attempt. -- The resolution of system timer is typically in the range of 10 milliseconds to 16 milliseconds. Thus, before the change, it may fail. Actually, it failed with Wine emulation. Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--common/sysutils.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/common/sysutils.c b/common/sysutils.c
index bbed309a8..ee9a25715 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -609,7 +609,7 @@ gnupg_tmpfile (void)
char *name, *p;
HANDLE file;
int pid = GetCurrentProcessId ();
- unsigned int value;
+ unsigned int value = 0;
int i;
SECURITY_ATTRIBUTES sec_attr;
@@ -634,12 +634,9 @@ gnupg_tmpfile (void)
for (attempts=0; attempts < 10; attempts++)
{
p = name;
- value = (GetTickCount () ^ ((pid<<16) & 0xffff0000));
+ value += (GetTickCount () ^ ((pid<<16) & 0xffff0000));
for (i=0; i < 8; i++)
- {
- *p++ = tohex (((value >> 28) & 0x0f));
- value <<= 4;
- }
+ *p++ = tohex (((value >> (7 - i)*4) & 0x0f));
strcpy (p, ".tmp");
file = CreateFile (buffer,
GENERIC_READ | GENERIC_WRITE,