Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2014-11-18 04:26:55 +0300
committerAdam Langley <agl@google.com>2014-11-19 04:24:46 +0300
commit69a01608f33ab6fe2c3485d94aef1fe9eacf5364 (patch)
tree82a6e6cd7402e7a237f03d4d8ca6c3ca76c885d7 /crypto/asn1/x_bignum.c
parentdeb52841381fdfa7d73b1855dd36798fbbe7a8bf (diff)
Add malloc failure tests.
This commit fixes a number of crashes caused by malloc failures. They were found using the -malloc-test=0 option to runner.go which runs tests many times, causing a different allocation call to fail in each case. (This test only works on Linux and only looks for crashes caused by allocation failures, not memory leaks or other errors.) This is not the complete set of crashes! More can be found by collecting core dumps from running with -malloc-test=0. Change-Id: Ia61d19f51e373bccb7bc604642c51e043a74bd83 Reviewed-on: https://boringssl-review.googlesource.com/2320 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/asn1/x_bignum.c')
-rw-r--r--crypto/asn1/x_bignum.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/asn1/x_bignum.c b/crypto/asn1/x_bignum.c
index 2ffa0930..7985235e 100644
--- a/crypto/asn1/x_bignum.c
+++ b/crypto/asn1/x_bignum.c
@@ -126,7 +126,13 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
int utype, char *free_cont, const ASN1_ITEM *it)
{
BIGNUM *bn;
- if(!*pval) bn_new(pval, it);
+ if(!*pval)
+ {
+ if (!bn_new(pval, it))
+ {
+ return 0;
+ }
+ }
bn = (BIGNUM *)*pval;
if(!BN_bin2bn(cont, len, bn)) {
bn_free(pval, it);