From: Klas Lindfors Date: Wed, 25 Apr 2012 12:54:07 +0000 (+0200) Subject: collect ndef uri properly. X-Git-Tag: v1.7.0~1^2~24 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6983d5f8ebc65473cc2f0963cf07911ecdc4308;p=yubikey-personalization collect ndef uri properly. --- diff --git a/ykpers-args.c b/ykpers-args.c index 1cae7f1..9074a4a 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -424,7 +424,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, if (!ykp_configure_command(cfg, SLOT_NDEF)) { return 0; } - ndef = strdup(optarg); + memcpy(ndef, optarg, strnlen(optarg, 128)); ndef_seen = true; break; case 'o': @@ -613,7 +613,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, } } - if (!slot_chosen) { + if (!slot_chosen && !ndef_seen) { fprintf(stderr, "A slot must be chosen with -1 or -2.\n"); *exit_code = 1; return 0; diff --git a/ykpersonalize.c b/ykpersonalize.c index ef01f14..d93a68c 100644 --- a/ykpersonalize.c +++ b/ykpersonalize.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) /* Options */ char *salt = NULL; - char *ndef = NULL; + char ndef_uri[128]; bool error = false; int exit_code = 0; @@ -125,7 +125,7 @@ int main(int argc, char **argv) &autocommit, salt, st, &verbose, access_code, &use_access_code, - &aesviahash, ndef, + &aesviahash, ndef_uri, &exit_code)) { goto err; }