From a52f3a648e7032ac47f6cd32f34dc09bdfb1004e Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 6 Sep 2021 22:34:06 +0200 Subject: [PATCH] Check for OK status code in chained replies. --- openpgp-card/src/apdu.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openpgp-card/src/apdu.rs b/openpgp-card/src/apdu.rs index 57718e8..2be0cad 100644 --- a/openpgp-card/src/apdu.rs +++ b/openpgp-card/src/apdu.rs @@ -51,7 +51,11 @@ pub(crate) fn send_command( expect_reply, )?)?; - // FIXME: first check for 0x61xx or 0x9000? + // Only continue if status is 0x61xx or 0x9000. + if next.status().0 != 0x61 && next.status() != (0x90, 0x0) { + return Err(Error::CardStatus(StatusByte::from(next.status()))); + } + log::debug!(" appending {} bytes to response", next.raw_data().len()); // Append new data to resp.data and overwrite status.