From b594ae0d39078f6480c126e09ed8aec819484bd3 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 18 Oct 2012 10:49:17 +0200 Subject: [PATCH] handle deleting configuration better if both slots are configured and one is deleted programming sequence will be counted up as usual. when the last slot is deleted programming sequence will be set to 0. try to handle this. --- ykcore/ykcore.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ykcore/ykcore.c b/ykcore/ykcore.c index 21a51b3..c938b83 100644 --- a/ykcore/ykcore.c +++ b/ykcore/ykcore.c @@ -212,11 +212,14 @@ int yk_write_command(YK_KEY *yk, YK_CONFIG *cfg, uint8_t command, return 0; yk_errno = YK_EWRITEERR; - if (cfg) { - return stat.pgmSeq != seq; - } - return stat.pgmSeq == 0; + /* when both configurations from a YubiKey is erased it will return + * pgmSeq 0, if one is still configured after an erase pgmSeq is + * counted up as usual. */ + if(!cfg && stat.pgmSeq == 0) { + return 1; + } + return stat.pgmSeq != seq; } int yk_write_config(YK_KEY *yk, YK_CONFIG *cfg, int confnum, -- 2.39.5