diff options
| author | tb <> | 2023-05-16 18:41:18 +0000 |
|---|---|---|
| committer | tb <> | 2023-05-16 18:41:18 +0000 |
| commit | a79b4e1a2cccf54e1d2f364852261b2fce8bdd5f (patch) | |
| tree | c1e57579d325b66ece7a34948a27868c48be7210 /src/regress/lib/libc | |
| parent | 30414b5f47175c7b20a567fb5648e4dc23bb5915 (diff) | |
| download | openbsd-a79b4e1a2cccf54e1d2f364852261b2fce8bdd5f.tar.gz openbsd-a79b4e1a2cccf54e1d2f364852261b2fce8bdd5f.tar.bz2 openbsd-a79b4e1a2cccf54e1d2f364852261b2fce8bdd5f.zip | |
ecdhtest: check malloc() return values
From Ilya Chipitsine
Diffstat (limited to '')
| -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; |
