From: levitte@gmail.com Date: Fri, 18 Sep 2009 10:51:18 +0000 (+0000) Subject: The return code from hex_modhex_decode() was incorrectly treated. X-Git-Tag: yubikey-personalisation_1.1-1~2^2~8 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d01a5a0d2052db3ee5d71c772abf98fc20bfccc6;p=yubikey-personalization The return code from hex_modhex_decode() was incorrectly treated. new_access_code was improperly set. git-svn-id: https://yubikey-personalization.googlecode.com/svn/trunk@205 b62f149e-849f-11dd-9899-c7ba65f7c4c7 --- diff --git a/ykpersonalize.c b/ykpersonalize.c index aa637a7..46f9944 100644 --- a/ykpersonalize.c +++ b/ykpersonalize.c @@ -245,7 +245,7 @@ int main(int argc, char **argv) int rc = hex_modhex_decode(access_code, &access_code_len, optarg, strlen(optarg), 12, 12, false); - if (rc < 0) { + if (rc <= 0) { fprintf(stderr, "Invalid access code string: %s\n", optarg); @@ -270,7 +270,7 @@ int main(int argc, char **argv) int rc = hex_modhex_decode(fixedbin, &fixedbinlen, fixed, fixedlen, 0, 16, true); - if (rc < 0) { + if (rc <= 0) { fprintf(stderr, "Invalid fixed string: %s\n", fixed); @@ -278,7 +278,6 @@ int main(int argc, char **argv) goto err; } ykp_set_fixed(cfg, fixedbin, fixedbinlen); - new_access_code = true; } else if (strncmp(optarg, "uid=", 4) == 0) { const char *uid = optarg+4; @@ -288,7 +287,7 @@ int main(int argc, char **argv) int rc = hex_modhex_decode(uidbin, &uidbinlen, uid, uidlen, 12, 12, false); - if (rc < 0) { + if (rc <= 0) { fprintf(stderr, "Invalid uid string: %s\n", uid); @@ -305,7 +304,7 @@ int main(int argc, char **argv) int rc = hex_modhex_decode (accbin, &accbinlen, acc, acclen, 12, 12, false); - if (rc < 0) { + if (rc <= 0) { fprintf(stderr, "Invalid access code string: %s\n", acc); @@ -313,6 +312,7 @@ int main(int argc, char **argv) goto err; } ykp_set_access_code(cfg, accbin, accbinlen); + new_access_code = true; } else if (strcmp(optarg, "tab-first") == 0) ykp_set_tktflag_TAB_FIRST(cfg, true);