diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:20:31 +0100 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:20:31 +0100 |
commit | 666a76652bcc82c5f85e1a658eab83b27e9e78a4 (patch) | |
tree | 7ef0770f47b0c4a691b4cbe2d9849ecbc8fa202c /src/crypto/keccak.c | |
parent | Merge pull request #3184 (diff) | |
parent | call _exit instead of abort in release mode (diff) | |
download | monero-666a76652bcc82c5f85e1a658eab83b27e9e78a4.tar.xz |
Merge pull request #3187
851bd057 call _exit instead of abort in release mode (moneromooo-monero)
Diffstat (limited to 'src/crypto/keccak.c')
-rw-r--r-- | src/crypto/keccak.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c index fc6d487c2..528a5406b 100644 --- a/src/crypto/keccak.c +++ b/src/crypto/keccak.c @@ -4,9 +4,20 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "hash-ops.h" #include "keccak.h" +static void local_abort(const char *msg) +{ + fprintf(stderr, "%s\n", msg); +#ifdef NDEBUG + _exit(1); +#else + abort(); +#endif +} + const uint64_t keccakf_rndc[24] = { 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, @@ -83,8 +94,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) if (mdlen <= 0 || mdlen > 200 || sizeof(st) != 200) { - fprintf(stderr, "Bad keccak use"); - abort(); + local_abort("Bad keccak use"); } rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; @@ -101,8 +111,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) // last block and padding if (inlen >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 || rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp)) { - fprintf(stderr, "Bad keccak use"); - abort(); + local_abort("Bad keccak use"); } memcpy(temp, in, inlen); |