diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2018-06-29 17:17:59 -0700 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2018-06-29 17:17:59 -0700 |
commit | a9001cfaca9ec16d1e1435367ff4c0941e3d32c7 (patch) | |
tree | 42684b4b6ac23de77220e373303a426a0a4c6698 | |
parent | baf70b97ca02400e19b5e4599a114acd607254b2 (diff) | |
download | openssl_tpm2_engine-a9001cfaca9ec16d1e1435367ff4c0941e3d32c7.tar.gz |
create_tpm2_key: correct error check
There's no check that we actually have a last argument and the check
to see if we have too many is wrong. All of this needs to be relative
to optind, so if optind != argc-1 we don't have the final file name.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | create_tpm2_key.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/create_tpm2_key.c b/create_tpm2_key.c index b99166c..3970333 100644 --- a/create_tpm2_key.c +++ b/create_tpm2_key.c @@ -694,9 +694,14 @@ int main(int argc, char **argv) } } + if (optind >= argc) { + printf("Too few arguments: Expected file name as last argument\n"); + usage(argv[0]); + } + filename = argv[argc - 1]; - if (argc < 2) { + if (optind < argc - 1) { printf("Unexpected additional arguments\n"); usage(argv[0]); } |