From 9b59e3bda8c137bff885db5b1f9150346e36e076 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Mon, 2 Dec 2013 11:33:44 -0800 Subject: Sanitize assert usage and refuse to compile with NDEBUG. There were quite a few places where assert() was used with side effects, making operation with NDEBUG non-functional. This commit fixes all the cases I know about, but also adds an #error on NDEBUG because the code is untested without assertions and may still have vulnerabilities if used without assert. --- src/key.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/key.cpp') diff --git a/src/key.cpp b/src/key.cpp index 2fd68fa56b..b57b7c506c 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -148,10 +148,13 @@ public: } void SetSecretBytes(const unsigned char vch[32]) { + bool ret; BIGNUM bn; BN_init(&bn); - assert(BN_bin2bn(vch, 32, &bn)); - assert(EC_KEY_regenerate_key(pkey, &bn)); + ret = BN_bin2bn(vch, 32, &bn); + assert(ret); + ret = EC_KEY_regenerate_key(pkey, &bn); + assert(ret); BN_clear_free(&bn); } -- cgit v1.2.3