call _exit instead of abort in release mode
Avoids cores being created, as they're nowadays often piped to some call home system
This commit is contained in:
parent
09d19c9139
commit
851bd057ec
|
@ -31,6 +31,7 @@
|
||||||
#define __STDC_WANT_LIB_EXT1__ 1
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef HAVE_EXPLICIT_BZERO
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +51,12 @@ void *memwipe(void *ptr, size_t n)
|
||||||
{
|
{
|
||||||
if (memset_s(ptr, n, 0, n))
|
if (memset_s(ptr, n, 0, n))
|
||||||
{
|
{
|
||||||
|
#ifdef NDEBUG
|
||||||
|
fprintf(stderr, "Error: memset_s failed\n");
|
||||||
|
_exit(1);
|
||||||
|
#else
|
||||||
abort();
|
abort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
SCARECROW // might as well...
|
SCARECROW // might as well...
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
@ -1635,7 +1635,11 @@ mdb_assert_fail(MDB_env *env, const char *expr_txt,
|
||||||
if (env->me_assert_func)
|
if (env->me_assert_func)
|
||||||
env->me_assert_func(env, buf);
|
env->me_assert_func(env, buf);
|
||||||
fprintf(stderr, "%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
|
#ifdef NDEBUG
|
||||||
|
_exit();
|
||||||
|
#else
|
||||||
abort();
|
abort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define mdb_assert0(env, expr, expr_txt) ((void) 0)
|
# define mdb_assert0(env, expr, expr_txt) ((void) 0)
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#define EASYLOGGING_CC
|
#define EASYLOGGING_CC
|
||||||
#include "easylogging++.h"
|
#include "easylogging++.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(AUTO_INITIALIZE_EASYLOGGINGPP)
|
#if defined(AUTO_INITIALIZE_EASYLOGGINGPP)
|
||||||
INITIALIZE_EASYLOGGINGPP
|
INITIALIZE_EASYLOGGINGPP
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,8 +37,12 @@ static void abort(int status, const std::string& reason) {
|
||||||
#if defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
|
#if defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
|
||||||
// Ignore msvc critical error dialog - break instead (on debug mode)
|
// Ignore msvc critical error dialog - break instead (on debug mode)
|
||||||
_asm int 3
|
_asm int 3
|
||||||
|
#else
|
||||||
|
#ifdef NDEBUG
|
||||||
|
::_exit(1);
|
||||||
#else
|
#else
|
||||||
::abort();
|
::abort();
|
||||||
|
#endif
|
||||||
#endif // defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
|
#endif // defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
//
|
//
|
||||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -43,6 +44,18 @@
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static void local_abort(const char *msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\n", msg);
|
||||||
|
#ifdef NDEBUG
|
||||||
|
_exit(1);
|
||||||
|
#else
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace crypto {
|
namespace crypto {
|
||||||
|
|
||||||
using std::abort;
|
using std::abort;
|
||||||
|
@ -467,7 +480,7 @@ POP_WARNINGS
|
||||||
ec_scalar sum, k, h;
|
ec_scalar sum, k, h;
|
||||||
boost::shared_ptr<rs_comm> buf(reinterpret_cast<rs_comm *>(malloc(rs_comm_size(pubs_count))), free);
|
boost::shared_ptr<rs_comm> buf(reinterpret_cast<rs_comm *>(malloc(rs_comm_size(pubs_count))), free);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
abort();
|
local_abort("malloc failure");
|
||||||
assert(sec_index < pubs_count);
|
assert(sec_index < pubs_count);
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
{
|
{
|
||||||
|
@ -486,7 +499,7 @@ POP_WARNINGS
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ge_frombytes_vartime(&image_unp, &image) != 0) {
|
if (ge_frombytes_vartime(&image_unp, &image) != 0) {
|
||||||
abort();
|
local_abort("invalid key image");
|
||||||
}
|
}
|
||||||
ge_dsm_precomp(image_pre, &image_unp);
|
ge_dsm_precomp(image_pre, &image_unp);
|
||||||
sc_0(&sum);
|
sc_0(&sum);
|
||||||
|
@ -505,7 +518,7 @@ POP_WARNINGS
|
||||||
random_scalar(sig[i].c);
|
random_scalar(sig[i].c);
|
||||||
random_scalar(sig[i].r);
|
random_scalar(sig[i].r);
|
||||||
if (ge_frombytes_vartime(&tmp3, &*pubs[i]) != 0) {
|
if (ge_frombytes_vartime(&tmp3, &*pubs[i]) != 0) {
|
||||||
abort();
|
local_abort("invalid pubkey");
|
||||||
}
|
}
|
||||||
ge_double_scalarmult_base_vartime(&tmp2, &sig[i].c, &tmp3, &sig[i].r);
|
ge_double_scalarmult_base_vartime(&tmp2, &sig[i].c, &tmp3, &sig[i].r);
|
||||||
ge_tobytes(&buf->ab[i].a, &tmp2);
|
ge_tobytes(&buf->ab[i].a, &tmp2);
|
||||||
|
|
|
@ -4,9 +4,20 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "hash-ops.h"
|
#include "hash-ops.h"
|
||||||
#include "keccak.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] =
|
const uint64_t keccakf_rndc[24] =
|
||||||
{
|
{
|
||||||
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
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)
|
if (mdlen <= 0 || mdlen > 200 || sizeof(st) != 200)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad keccak use");
|
local_abort("Bad keccak use");
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen;
|
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
|
// 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))
|
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");
|
local_abort("Bad keccak use");
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(temp, in, inlen);
|
memcpy(temp, in, inlen);
|
||||||
|
|
|
@ -45,7 +45,11 @@ static void generate_system_random_bytes(size_t n, void *result);
|
||||||
|
|
||||||
static void generate_system_random_bytes(size_t n, void *result) {
|
static void generate_system_random_bytes(size_t n, void *result) {
|
||||||
HCRYPTPROV prov;
|
HCRYPTPROV prov;
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define must_succeed(x) do if (!(x)) { fprintf(stderr, "Failed: " #x); _exit(1); } while (0)
|
||||||
|
#else
|
||||||
#define must_succeed(x) do if (!(x)) abort(); while (0)
|
#define must_succeed(x) do if (!(x)) abort(); while (0)
|
||||||
|
#endif
|
||||||
must_succeed(CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT));
|
must_succeed(CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT));
|
||||||
must_succeed(CryptGenRandom(prov, (DWORD)n, result));
|
must_succeed(CryptGenRandom(prov, (DWORD)n, result));
|
||||||
must_succeed(CryptReleaseContext(prov, 0));
|
must_succeed(CryptReleaseContext(prov, 0));
|
||||||
|
|
Loading…
Reference in New Issue