From 6d8f7b62b3e2bcdb5497a803cba0371d43b1b881 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Sat, 12 Jan 2019 14:37:34 -0800 Subject: [PATCH] Fix bug where old i counter used instead of ret val for arg location --- wolfCLU/README.md | 3 ++- wolfCLU/clu_include/clu_optargs.h | 2 +- wolfCLU/clu_src/hash/clu_hash_setup.c | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wolfCLU/README.md b/wolfCLU/README.md index 3667efbd..eef29644 100644 --- a/wolfCLU/README.md +++ b/wolfCLU/README.md @@ -6,7 +6,8 @@ This is the wolfSSL: Command Line Utility (wolfCLU). To use this feature, please configure and install wolfssl with the following commands: - ./configure --enable-pwdbased --enable-opensslextra --enable-keygen --enable-ed25519 + ./configure --enable-pwdbased --enable-opensslextra --enable-keygen \ + --enable-ed25519 --enable-certgen \ && make && make check If that succeeds, run: diff --git a/wolfCLU/clu_include/clu_optargs.h b/wolfCLU/clu_include/clu_optargs.h index 265ea356..3cd97f98 100644 --- a/wolfCLU/clu_include/clu_optargs.h +++ b/wolfCLU/clu_include/clu_optargs.h @@ -33,7 +33,7 @@ enum { RSA, ECC, ED25519, - + CERT_SHA, CERT_SHA224, CERT_SHA256, diff --git a/wolfCLU/clu_src/hash/clu_hash_setup.c b/wolfCLU/clu_src/hash/clu_hash_setup.c index 86c9a084..813d82cb 100644 --- a/wolfCLU/clu_src/hash/clu_hash_setup.c +++ b/wolfCLU/clu_src/hash/clu_hash_setup.c @@ -88,10 +88,14 @@ int wolfCLU_hashSetup(int argc, char** argv) return FATAL_ERROR; } + /* returns location of the arg in question if present */ ret = wolfCLU_checkForArg("-in", 3, argc, argv); if (ret > 0) { /* input file/text */ - in = XMALLOC(strlen(argv[i+1])+1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + int argLen = (int) XSTRLEN(argv[ret+1]); + int fullLen = (int) ((argLen + 1) * sizeof(char)); + + in = XMALLOC(fullLen, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (in == NULL) return MEMORY_E;