]> err.no Git - yubikey-personalization/commitdiff
collect ndef uri properly.
authorKlas Lindfors <klas@yubico.com>
Wed, 25 Apr 2012 12:54:07 +0000 (14:54 +0200)
committerKlas Lindfors <klas@yubico.com>
Wed, 25 Apr 2012 12:54:07 +0000 (14:54 +0200)
ykpers-args.c
ykpersonalize.c

index 1cae7f1a83fcf01927473a978fb1efe5dd17b842..9074a4a6b1636dbfaca393082e9a42328b372ea5 100644 (file)
@@ -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;
index ef01f14ecea4a100cda4ef83f519ee2e26c7eae1..d93a68c85f00bb08347b03e1243776d46b95605c 100644 (file)
@@ -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;
        }