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
path: root/crypto
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-02-09 07:20:06 +0300
committerAdam Langley <agl@google.com>2015-02-09 22:39:41 +0300
commit1eed2c0e40ad363da9b00966e1b19f451dee8fad (patch)
tree1f1f253a79dd9f950e5c4944cdcc4d8814faed9b /crypto
parent42ca3a46236b0456109e71af754a09d8da7d4b0c (diff)
Fix some unchecked mallocs.
BUG=456599 Change-Id: Id0652c2aff1cb8a5de35350feb8410285b3fef20 Reviewed-on: https://boringssl-review.googlesource.com/3330 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/rand/urandom.c4
-rw-r--r--crypto/x509/by_dir.c6
-rw-r--r--crypto/x509v3/v3_alt.c2
3 files changed, 12 insertions, 0 deletions
diff --git a/crypto/rand/urandom.c b/crypto/rand/urandom.c
index 2ad4af06..a7e2ad82 100644
--- a/crypto/rand/urandom.c
+++ b/crypto/rand/urandom.c
@@ -188,6 +188,10 @@ int RAND_bytes(uint8_t *out, size_t requested) {
if (!buf) {
buf = (struct rand_buffer *)OPENSSL_malloc(BUF_SIZE);
+ if (!buf) {
+ abort();
+ return 0;
+ }
/* The buffer doesn't contain any random bytes yet
* so we mark it as fully used so that it will be
* filled below. */
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 5a77b818..3573c86f 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -442,6 +442,12 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
if (!hent)
{
hent = OPENSSL_malloc(sizeof(BY_DIR_HASH));
+ if (hent == NULL)
+ {
+ CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+ ok = 0;
+ goto finish;
+ }
hent->hash = h;
hent->suffix = k;
if (!sk_BY_DIR_HASH_push(ent->hashes, hent))
diff --git a/crypto/x509v3/v3_alt.c b/crypto/x509v3/v3_alt.c
index 113cf45a..f547316e 100644
--- a/crypto/x509v3/v3_alt.c
+++ b/crypto/x509v3/v3_alt.c
@@ -583,6 +583,8 @@ static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
return 0;
objlen = p - value;
objtmp = OPENSSL_malloc(objlen + 1);
+ if (objtmp == NULL)
+ return 0;
strncpy(objtmp, value, objlen);
objtmp[objlen] = 0;
gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);