From 6989ae6c945b3e4d4a8f9603d60a5712ce76e306 Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Mon, 25 Sep 2023 11:21:42 +0100 Subject: [PATCH 1/5] ensure arg for -p --- src/cli.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cli.cpp b/src/cli.cpp index 56dbf8e..5c7d6be 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -183,6 +183,10 @@ int CLI::parseCommandLine(int argc, char* argv[], Options* options) { } i++; } else if (arg == "-p" || arg == "--productid") { + if (i == argc -1) { + options->error = true; + break; + } options->productid = argv[i+1]; i++; } else if (arg == "-V" || arg == "--validate") { From ecd9cd8dd2c0310eeeddf88b481f8fce97c2b2ee Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Mon, 25 Sep 2023 11:26:28 +0100 Subject: [PATCH 2/5] office 2k7 enterprise must be given inst id --- src/cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.cpp b/src/cli.cpp index 5c7d6be..1d38966 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -207,7 +207,7 @@ int CLI::parseCommandLine(int argc, char* argv[], Options* options) { } // make sure that a product id is entered for OFFICE_2K3 or OFFICE_2K7 IIDs - if ((options->activationMode == OFFICE_2K3 || options->activationMode == OFFICE_2K7) && options->productid == "") { + if ((options->activationMode == OFFICE_2K3 || options->activationMode == OFFICE_2K7) && (options->productid.empty() || options->instid.empty()) ) { return options->error = true; } From 12a041c380730859a3ded708d51bdc0ada26b6b1 Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Mon, 25 Sep 2023 12:04:52 +0100 Subject: [PATCH 3/5] BN_free() memleaks --- src/libumskt/pidgen3/util.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libumskt/pidgen3/util.cpp b/src/libumskt/pidgen3/util.cpp index b6aad7b..2255af5 100644 --- a/src/libumskt/pidgen3/util.cpp +++ b/src/libumskt/pidgen3/util.cpp @@ -100,6 +100,13 @@ EC_GROUP* PIDGEN3::initializeEllipticCurve( // Cleanup BN_CTX_free(context); + BN_free(p); + BN_free(a); + BN_free(b); + BN_free(generatorX); + BN_free(generatorY); + BN_free(publicKeyX); + BN_free(publicKeyY); return eCurve; } From bf40bb64028e9340dc1778c3afe5dbd0da26da6c Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Mon, 25 Sep 2023 12:10:42 +0100 Subject: [PATCH 4/5] CLI moved to stack object --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 558a5b7..31234b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,23 +39,23 @@ int main(int argc, char *argv[]) { return status; } - CLI* run = new CLI(options, keys); + CLI run(options, keys); switch(options.applicationMode) { case MODE_BINK1998_GENERATE: - return run->BINK1998Generate(); + return run.BINK1998Generate(); case MODE_BINK2002_GENERATE: - return run->BINK2002Generate(); + return run.BINK2002Generate(); case MODE_BINK1998_VALIDATE: - return run->BINK1998Validate(); + return run.BINK1998Validate(); case MODE_BINK2002_VALIDATE: - return run->BINK2002Validate(); + return run.BINK2002Validate(); case MODE_CONFIRMATION_ID: - return run->ConfirmationID(); + return run.ConfirmationID(); default: return 1; From 5ba2dbddd46863005885f38c98a744a2ac83d18d Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Mon, 25 Sep 2023 12:05:23 +0100 Subject: [PATCH 5/5] EC/BN memleak --- src/cli.cpp | 10 ++++++++++ src/cli.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/cli.cpp b/src/cli.cpp index 1d38966..df1ccf0 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -22,6 +22,15 @@ #include "cli.h" +CLI::~CLI() +{ + EC_GROUP_free(eCurve); + EC_POINT_free(genPoint); + EC_POINT_free(pubPoint); + BN_free(privateKey); + BN_free(genOrder); +} + bool CLI::loadJSON(const fs::path& filename, json *output) { if (!filename.empty() && !fs::exists(filename)) { fmt::print("ERROR: File {} does not exist\n", filename.string()); @@ -417,6 +426,7 @@ int CLI::BINK1998Generate() { sscanf(cRaw, "%d", &oRaw); nRaw += (oRaw % 999999); // ensure our serial is less than 999999 + BN_free(bnrand); } if (this->options.verbose) { diff --git a/src/cli.h b/src/cli.h index 0c80bf7..c73104a 100644 --- a/src/cli.h +++ b/src/cli.h @@ -85,6 +85,7 @@ class CLI { public: CLI(Options options, json keys); + ~CLI(); static bool loadJSON(const fs::path& filename, json *output); static void showHelp(char *argv[]);