If a command fails, card_status will not match VCARD_DONE. That will trigger the assert and abort the process. Instead, handle VCARD_FAIL and return an error in that case. Client software can then deal with the error, and we continue running to handle future commands. This can be triggered by removing the physical smartcard mid-operation. Signed-off-by: Jason Andryuk <jandryuk@xxxxxxxxx> --- src/vreader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vreader.c b/src/vreader.c index 2d8aa9f..148f65b 100644 --- a/src/vreader.c +++ b/src/vreader.c @@ -256,6 +256,7 @@ vreader_xfr_bytes(VReader *reader, VCardAPDU *apdu; VCardResponse *response = NULL; VCardStatus card_status; + VReaderStatus ret; unsigned short status; VCard *card = vreader_get_card(reader); int size; @@ -279,14 +280,23 @@ vreader_xfr_bytes(VReader *reader, response->b_sw2, response->b_len, response->b_total_len); } } + if (card_status == VCARD_FAIL) { + *receive_buf_len = 0; + ret = VREADER_NO_CARD; + goto exit; + } + assert(card_status == VCARD_DONE && response); size = MIN(*receive_buf_len, response->b_total_len); memcpy(receive_buf, response->b_data, size); *receive_buf_len = size; + ret = VREADER_OK; + + exit: vcard_response_delete(response); vcard_apdu_delete(apdu); vcard_free(card); /* free our reference */ - return VREADER_OK; + return ret; } struct VReaderListStruct { -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel