1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

sm: On Windows close the kbx files at several places.

* kbx/keybox-search.c (keybox_search_reset) [W32]: Always close.

* kbx/keybox-init.c (keybox_close_all_files): New.
* sm/keydb.c (keydb_close_all_files): New.
* sm/call-dirmngr.c (gpgsm_dirmngr_isvalid): Call new function.
(gpgsm_dirmngr_lookup): Ditto.
(gpgsm_dirmngr_run_command): Ditto.
--

We need to make sure that there are no open files on Windows.  Thus we
close them at several strategic locations.

GnuPG-bug-id: 4505
This commit is contained in:
Werner Koch 2021-03-02 19:01:07 +01:00
parent c99f3599d8
commit 2b9ae79ad8
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
6 changed files with 56 additions and 1 deletions

View file

@ -261,6 +261,26 @@ _keybox_close_file (KEYBOX_HANDLE hd)
}
/* Close all the files associated with the resource identified by TOKEN. */
void
keybox_close_all_files (void *token)
{
KB_NAME resource = token;
KEYBOX_HANDLE roverhd;
int idx;
if (!resource)
return;
for (idx=0; idx < resource->handle_table_size; idx++)
if ((roverhd = resource->handle_table[idx]) && roverhd->fp)
{
es_fclose (roverhd->fp);
roverhd->fp = NULL;
}
}
/*
* Lock the keybox at handle HD, or unlock if YES is false.
* Lock the keybox at handle HD, or unlock if YES is false. TIMEOUT

View file

@ -814,6 +814,10 @@ keybox_search_reset (KEYBOX_HANDLE hd)
if (hd->fp)
{
#if HAVE_W32_SYSTEM
es_fclose (hd->fp);
hd->fp = NULL;
#else
if (es_fseeko (hd->fp, 0, SEEK_SET))
{
/* Ooops. Seek did not work. Close so that the search will
@ -821,6 +825,7 @@ keybox_search_reset (KEYBOX_HANDLE hd)
es_fclose (hd->fp);
hd->fp = NULL;
}
#endif
}
hd->error = 0;
hd->eof = 0;

View file

@ -70,6 +70,8 @@ int keybox_is_writable (void *token);
KEYBOX_HANDLE keybox_new_openpgp (void *token, int secret);
KEYBOX_HANDLE keybox_new_x509 (void *token, int secret);
void keybox_close_all_files (void *token);
void keybox_release (KEYBOX_HANDLE hd);
void keybox_push_found_state (KEYBOX_HANDLE hd);
void keybox_pop_found_state (KEYBOX_HANDLE hd);