summaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2024-09-19 06:44:56 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2024-09-19 06:44:56 +0200
commitb804378f183f7845dcdef8a953833f62684edfa7 (patch)
tree512a35c4c05a512a123f30f658742ff08503eacb /kbx
parentscd: Fix DEVINFO to allow multiple clients. (diff)
downloadgnupg2-b804378f183f7845dcdef8a953833f62684edfa7.tar.xz
gnupg2-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 <gniibe@fsij.org>
Diffstat (limited to 'kbx')
-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. */