diff options
author | NIIBE Yutaka <[email protected]> | 2024-09-19 04:44:56 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2024-09-19 11:24:28 +0000 |
commit | a698adbb533fac12277aaf319ab08d0e7f027261 (patch) | |
tree | e7e2e3eaf726de0ebf9f9226d95a5ce6ce5c59c6 | |
parent | scd: Fix DEVINFO to allow multiple clients. (diff) | |
download | gnupg-a698adbb533fac12277aaf319ab08d0e7f027261.tar.gz gnupg-a698adbb533fac12277aaf319ab08d0e7f027261.zip |
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 <[email protected]>
-rw-r--r-- | kbx/backend-sqlite.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/kbx/backend-sqlite.c b/kbx/backend-sqlite.c index ec891da6d..50ab6f08b 100644 --- a/kbx/backend-sqlite.c +++ b/kbx/backend-sqlite.c @@ -568,11 +568,14 @@ create_or_open_database (ctrl_t ctrl, const char *filename) int dbversion; int setdbversion = 0; - if (database_hd) - return 0; /* Already initialized. */ - acquire_mutex (); + if (database_hd) + { + release_mutex (); + return 0; /* Already initialized. */ + } + /* To avoid races with other temporary instances of keyboxd trying * to create or update the database, we run the database with a lock * file held. */ |