aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-09-19 04:44:56 +0000
committerNIIBE Yutaka <[email protected]>2024-09-19 04:44:56 +0000
commitb804378f183f7845dcdef8a953833f62684edfa7 (patch)
tree512a35c4c05a512a123f30f658742ff08503eacb
parentscd: Fix DEVINFO to allow multiple clients. (diff)
downloadgnupg-b804378f183f7845dcdef8a953833f62684edfa7.tar.gz
gnupg-b804378f183f7845dcdef8a953833f62684edfa7.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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kbx/backend-sqlite.c b/kbx/backend-sqlite.c
index 2398aa77f..4c67c3ef7 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. */