1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

kbx: Fix a race condition on DATABASE_HD.

* kbx/backend-sqlite.c (create_or_open_database): Protect
the access to DATABASE_HD.

--

GnuPG-bug-id: 7294
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2024-09-19 13:44:56 +09:00 committed by Werner Koch
parent 32476f870d
commit a698adbb53
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -568,11 +568,14 @@ create_or_open_database (ctrl_t ctrl, const char *filename)
int dbversion; int dbversion;
int setdbversion = 0; int setdbversion = 0;
if (database_hd)
return 0; /* Already initialized. */
acquire_mutex (); acquire_mutex ();
if (database_hd)
{
release_mutex ();
return 0; /* Already initialized. */
}
/* To avoid races with other temporary instances of keyboxd trying /* To avoid races with other temporary instances of keyboxd trying
* to create or update the database, we run the database with a lock * to create or update the database, we run the database with a lock
* file held. */ * file held. */