diff options
author | tb <> | 2023-05-16 18:41:18 +0000 |
---|---|---|
committer | tb <> | 2023-05-16 18:41:18 +0000 |
commit | b36a9f1697cdcaa5ea871949d17a1b748ed8b0a2 (patch) | |
tree | c1e57579d325b66ece7a34948a27868c48be7210 /src | |
parent | e42d8f4b21a8a498e2eabbffe4c7b7d4ef7cec54 (diff) | |
download | openbsd-b36a9f1697cdcaa5ea871949d17a1b748ed8b0a2.tar.gz openbsd-b36a9f1697cdcaa5ea871949d17a1b748ed8b0a2.tar.bz2 openbsd-b36a9f1697cdcaa5ea871949d17a1b748ed8b0a2.zip |
ecdhtest: check malloc() return values
From Ilya Chipitsine
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/ecdh/ecdhtest.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/regress/lib/libcrypto/ecdh/ecdhtest.c b/src/regress/lib/libcrypto/ecdh/ecdhtest.c index e6046a5400..415414bdc0 100644 --- a/src/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/src/regress/lib/libcrypto/ecdh/ecdhtest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecdhtest.c,v 1.14 2023/04/26 09:31:12 tb Exp $ */ | 1 | /* $OpenBSD: ecdhtest.c,v 1.15 2023/05/16 18:41:18 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -146,7 +146,8 @@ test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) | |||
146 | (void)BIO_flush(out); | 146 | (void)BIO_flush(out); |
147 | 147 | ||
148 | alen = KDF1_SHA1_len; | 148 | alen = KDF1_SHA1_len; |
149 | abuf = malloc(alen); | 149 | if ((abuf = malloc(alen)) == NULL) |
150 | goto err; | ||
150 | aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), | 151 | aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), |
151 | a, KDF1_SHA1); | 152 | a, KDF1_SHA1); |
152 | 153 | ||
@@ -154,7 +155,8 @@ test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) | |||
154 | (void)BIO_flush(out); | 155 | (void)BIO_flush(out); |
155 | 156 | ||
156 | blen = KDF1_SHA1_len; | 157 | blen = KDF1_SHA1_len; |
157 | bbuf = malloc(blen); | 158 | if ((bbuf = malloc(blen)) == NULL) |
159 | goto err; | ||
158 | bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), | 160 | bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), |
159 | b, KDF1_SHA1); | 161 | b, KDF1_SHA1); |
160 | 162 | ||
@@ -344,7 +346,8 @@ ecdh_kat(BIO *out, const char *cname, int nid, | |||
344 | Ztmplen = ECDH_size(key1); | 346 | Ztmplen = ECDH_size(key1); |
345 | if (Ztmplen != Zlen) | 347 | if (Ztmplen != Zlen) |
346 | goto err; | 348 | goto err; |
347 | Ztmp = malloc(Ztmplen); | 349 | if ((Ztmp = malloc(Ztmplen)) == NULL) |
350 | goto err; | ||
348 | if (!ECDH_compute_key(Ztmp, Ztmplen, | 351 | if (!ECDH_compute_key(Ztmp, Ztmplen, |
349 | EC_KEY_get0_public_key(key2), key1, 0)) | 352 | EC_KEY_get0_public_key(key2), key1, 0)) |
350 | goto err; | 353 | goto err; |