From 3cf5fc2e2f640a7ad0466b8b5a9bc0108521aa01 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 1 May 2023 11:36:36 +0900 Subject: [PATCH] scd: Fix cmd_apdu on error. * scd/command.c (cmd_apdu): Fix the code path on error. -- GnuPG-bug-id: 6476 Reported-by: Robin Krahl Signed-off-by: NIIBE Yutaka --- scd/apdu.c | 2 +- scd/command.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scd/apdu.c b/scd/apdu.c index ffada1d78..deb1134e6 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -3260,7 +3260,7 @@ apdu_send_simple (int slot, int extended_mode, * Out of historical reasons the function returns 0 on success and * outs the status word at the end of the result to be able to get the * status word in the case of a not provided RETBUF, R_SW can be used - * to store the SW. But note that R_SW qill only be set if the + * to store the SW. But note that R_SW will only be set if the * function returns 0. */ int apdu_send_direct (int slot, size_t extended_length, diff --git a/scd/command.c b/scd/command.c index 635bb350e..0cf66d08c 100644 --- a/scd/command.c +++ b/scd/command.c @@ -2200,7 +2200,10 @@ cmd_apdu (assuan_context_t ctx, char *line) apdu, apdulen, handle_more, NULL, &result, &resultlen); if (rc) - log_error ("apdu_send_direct failed: %s\n", gpg_strerror (rc)); + { + log_error ("apdu_send_direct failed: %s\n", apdu_strerror (rc)); + rc = iso7816_map_sw (rc); + } else { rc = assuan_send_data (ctx, result, resultlen);