diff options
author | NIIBE Yutaka <[email protected]> | 2016-07-19 01:53:39 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2016-11-29 08:15:20 +0000 |
commit | 3b3386a3fd973ed7f388b1356138941c302848f2 (patch) | |
tree | a2e76a01ca6d1a21792574f3dd2a35f25b0afa6a | |
parent | scd: Make option --homedir work. (diff) | |
download | gnupg-3b3386a3fd973ed7f388b1356138941c302848f2.tar.gz gnupg-3b3386a3fd973ed7f388b1356138941c302848f2.zip |
scd: Fix race conditions for release_application.
* scd/command.c (do_reset, cmd_restart): Reset app_ctx before calling
release_application.
--
Backport of master commit: 0c1fd4e9884ed7c1edd1819762b9e8a77f606ed3
Thanks to Ben Warren for the report.
Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r-- | scd/command.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/scd/command.c b/scd/command.c index 44f0b21bd..24c51c869 100644 --- a/scd/command.c +++ b/scd/command.c @@ -283,6 +283,7 @@ static void do_reset (ctrl_t ctrl, int send_reset) { int slot = ctrl->reader_slot; + struct app_ctx_s *app = ctrl->app_ctx; if (!(slot == -1 || (slot >= 0 && slot < DIM(slot_table)))) BUG (); @@ -290,10 +291,10 @@ do_reset (ctrl_t ctrl, int send_reset) /* If there is an active application, release it. Tell all other sessions using the same application to release the application. */ - if (ctrl->app_ctx) + if (app) { - release_application (ctrl->app_ctx); ctrl->app_ctx = NULL; + release_application (app); if (send_reset) { struct server_local_s *sl; @@ -1744,13 +1745,14 @@ static gpg_error_t cmd_restart (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + struct app_ctx_s *app = ctrl->app_ctx; (void)line; - if (ctrl->app_ctx) + if (app) { - release_application (ctrl->app_ctx); ctrl->app_ctx = NULL; + release_application (app); } if (locked_session && ctrl->server_local == locked_session) { |