From: Richard Levitte 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.3.5-1~4^2~53 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b70d2371da480e6a198b0feba05d5fdb4568de9b;p=yubikey-personalization.old The return code from hex_modhex_decode() was incorrectly treated. new_access_code was improperly set. --- 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);