mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
kbx: Fix deadlock in gpgsm on Windows due to a sharing violation.
* kbx/keybox-init.c (keybox_lock) [W32]: Use _keybox_close_file instead of fclose so that a close is done if the file is opened by another handle. * kbx/keybox-search.c (keybox_search): Remember the last offset and use that in NEXT search mode if we had to re-open the file. -- GnuPG-bug-id: 4505 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
22e274f839
commit
49b236af0e
3 changed files with 42 additions and 14 deletions
|
@ -291,18 +291,14 @@ keybox_lock (KEYBOX_HANDLE hd, int yes, long timeout)
|
|||
if (!kb->is_locked)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Under Windows we need to close the file before we try
|
||||
* to lock it. This is because another process might have
|
||||
* taken the lock and is using keybox_file_rename to
|
||||
* rename the base file. How if our dotlock_take below is
|
||||
* waiting for the lock but we have the base file still
|
||||
* open, keybox_file_rename will never succeed as we are
|
||||
* in a deadlock. */
|
||||
if (hd->fp)
|
||||
{
|
||||
fclose (hd->fp);
|
||||
hd->fp = NULL;
|
||||
}
|
||||
/* Under Windows we need to close the file before we try
|
||||
* to lock it. This is because another process might have
|
||||
* taken the lock and is using keybox_file_rename to
|
||||
* rename the base file. Now if our dotlock_take below is
|
||||
* waiting for the lock but we have the base file still
|
||||
* open, keybox_file_rename will never succeed as we are
|
||||
* in a deadlock. */
|
||||
_keybox_close_file (hd);
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
if (dotlock_take (kb->lockhd, timeout))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue