From: Klas Lindfors Date: Thu, 18 Oct 2012 08:49:17 +0000 (+0200) Subject: handle deleting configuration better X-Git-Tag: v1.9.0~16 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b594ae0d39078f6480c126e09ed8aec819484bd3;p=yubikey-personalization 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. --- 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,