From 6541cf32f8a50ce40354b714a419377c37886bf3 Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Wed, 13 Mar 2024 14:24:03 +0100 Subject: [PATCH] Clear return buffer in case of error --- src/gpg_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gpg_main.c b/src/gpg_main.c index fb17459..d0da2fd 100644 --- a/src/gpg_main.c +++ b/src/gpg_main.c @@ -50,6 +50,9 @@ void app_main(void) { sw = gpg_dispatch(); if (sw) { PRINTF("[MAIN] - FINALLY INSERT sw=0x%x\n", sw); + if ((sw != SW_OK) && ((sw & 0xFF00) != SW_CORRECT_BYTES_AVAILABLE)) { + gpg_io_discard(1); + } gpg_io_insert_u16(sw); io_flags = 0; } else {