aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-06-26 02:13:05 +0000
committerWerner Koch <[email protected]>2024-07-01 12:16:48 +0000
commit59e785b5434d7cd950b0ed3878e278b97fde945b (patch)
tree1133ad771c4c2de474079dee5190d4c5516d4907
parentscd: Finish DEVINFO --watch command on input close. (diff)
downloadgnupg-59e785b5434d7cd950b0ed3878e278b97fde945b.tar.gz
gnupg-59e785b5434d7cd950b0ed3878e278b97fde945b.zip
scd: Restrict use of DEVINFO --watch command for socket connection.
* scd/app.c (app_send_devinfo): Return GPG_ERR_INV_HANDLE when it's not socket when KEEP_LOOPING != 0. -- GnuPG-bug-id: 7151 Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit d98521b934ec6a5abb0ad18e39a26009a8806c52)
-rw-r--r--scd/app.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/scd/app.c b/scd/app.c
index 4077db69b..9d838cff0 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -484,7 +484,7 @@ app_dump_state (void)
*
* With KEEP_LOOPING=0, it only outputs once.
* With KEEP_LOOPING<0, it keeps looping, until it detects no device.
- * With KEEP_LOOPING>0, it keeps looping forever.
+ * With KEEP_LOOPING>0, it keeps looping forever (until connection close).
*/
gpg_error_t
app_send_devinfo (ctrl_t ctrl, int keep_looping)
@@ -493,6 +493,13 @@ app_send_devinfo (ctrl_t ctrl, int keep_looping)
app_t a;
int no_device;
+ /* The connection from client should be by a socket. This is needed
+ for Windows using the select function. And it's not good to use
+ the primary pipe connection of gpg-agent for watching
+ devinfo. */
+ if (keep_looping && ctrl->thread_startup.fd == GNUPG_INVALID_FD)
+ return gpg_error (GPG_ERR_INV_HANDLE);
+
card_list_w_lock ();
while (1)
{