Merge commit 'a2b9adafe46c55a2c26dd46163055bbdf3526835'

This commit is contained in:
Marcus Brinkmann 2011-02-02 13:51:42 +01:00
commit de287a7996
2 changed files with 21 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2011-02-02 Marcus Brinkmann <mb@g10code.com>
* w32-util.c (mkstemp): Don't use CreateFile instead of open (the
function is not used on Windows CE, and the callers were not
adjusted).
2011-01-21 Marcus Brinkmann <mb@g10code.com> 2011-01-21 Marcus Brinkmann <mb@g10code.com>
* engine-gpgconf.c (_gpgme_conf_opt_change): Fix the case that is * engine-gpgconf.c (_gpgme_conf_opt_change): Fix the case that is

View File

@ -476,6 +476,14 @@ _gpgme_get_conf_int (const char *key, int *value)
} }
#ifdef HAVE_W32CE_SYSTEM
int
_gpgme_mkstemp (int *fd, char **name)
{
return -1;
}
#else
/* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright /* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright
(C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc. (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
@ -499,7 +507,7 @@ mkstemp (char *tmpl)
static uint64_t value; static uint64_t value;
uint64_t random_time_bits; uint64_t random_time_bits;
unsigned int count; unsigned int count;
HANDLE fd = INVALID_HANDLE_VALUE; int fd = -1;
int save_errno = errno; int save_errno = errno;
/* A lower bound on the number of temporary files to attempt to /* A lower bound on the number of temporary files to attempt to
@ -555,24 +563,15 @@ mkstemp (char *tmpl)
v /= 62; v /= 62;
XXXXXX[5] = letters[v % 62]; XXXXXX[5] = letters[v % 62];
fd = CreateFileA (tmpl, fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
GENERIC_WRITE|GENERIC_READ, if (fd >= 0)
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (fd != INVALID_HANDLE_VALUE)
{ {
gpg_err_set_errno (save_errno); gpg_err_set_errno (save_errno);
return (int)fd; return fd;
} }
else if (GetLastError () != ERROR_FILE_EXISTS) else if (errno != EEXIST)
{
gpg_err_set_errno (EIO);
return -1; return -1;
} }
}
/* We got out of the loop because we ran out of combinations to try. */ /* We got out of the loop because we ran out of combinations to try. */
gpg_err_set_errno (EEXIST); gpg_err_set_errno (EEXIST);
@ -616,6 +615,7 @@ _gpgme_mkstemp (int *fd, char **name)
*name = tmpname; *name = tmpname;
return 0; return 0;
} }
#endif