diff options
author | Bodo Möller <bodo@openssl.org> | 2000-09-04 15:34:43 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2000-09-04 15:34:43 +0000 |
commit | bbb8de0966f0181498a0491f42d8b839778a93e7 (patch) | |
tree | 5a645a6357da154d8a320950a302cdf6f1d7e793 /crypto/bn | |
parent | 5e386163801a248063afbc9e346ab1b098356729 (diff) |
Avoid abort() throughout the library, except when preprocessor
symbols for debugging are defined.
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_asm.c | 11 | ||||
-rw-r--r-- | crypto/bn/bn_lib.c | 14 | ||||
-rw-r--r-- | crypto/bn/vms-helper.c | 2 |
3 files changed, 12 insertions, 15 deletions
diff --git a/crypto/bn/bn_asm.c b/crypto/bn/bn_asm.c index 3329cc18e6..44e52a40db 100644 --- a/crypto/bn/bn_asm.c +++ b/crypto/bn/bn_asm.c @@ -227,7 +227,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) #else -/* Divide h-l by d and return the result. */ +/* Divide h,l by d and return the result. */ /* I need to test this some more :-( */ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { @@ -237,13 +237,8 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) if (d == 0) return(BN_MASK2); i=BN_num_bits_word(d); - if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i)) - { -#if !defined(NO_STDIO) && !defined(WIN16) - fprintf(stderr,"Division would overflow (%d)\n",i); -#endif - abort(); - } + assert((i == BN_BITS2) || (h > (BN_ULONG)1<<i)); + i=BN_BITS2-i; if (h >= d) h-=d; diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index b693c7e0c0..b6b0ce4b3c 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -56,6 +56,12 @@ * [including the GNU Public Licence.] */ +#ifndef BN_DEBUG +# undef NDEBUG /* avoid conflicting definitions */ +# define NDEBUG +#endif + +#include <assert.h> #include <stdio.h> #include "cryptlib.h" #include "bn_lcl.h" @@ -244,14 +250,8 @@ int BN_num_bits(const BIGNUM *a) if (a->top == 0) return(0); l=a->d[a->top-1]; + assert(l != 0); i=(a->top-1)*BN_BITS2; - if (l == 0) - { -#if !defined(NO_STDIO) && !defined(WIN16) - fprintf(stderr,"BAD TOP VALUE\n"); -#endif - abort(); - } return(i+BN_num_bits_word(l)); } diff --git a/crypto/bn/vms-helper.c b/crypto/bn/vms-helper.c index 73af337069..0fa79c4edb 100644 --- a/crypto/bn/vms-helper.c +++ b/crypto/bn/vms-helper.c @@ -59,8 +59,10 @@ bn_div_words_abort(int i) { +#ifdef BN_DEBUG #if !defined(NO_STDIO) && !defined(WIN16) fprintf(stderr,"Division would overflow (%d)\n",i); #endif abort(); +#endif } |