mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
9f7ff43672
commit
ce5bed2800
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user