diff options
author | tb <> | 2024-11-05 18:20:08 +0000 |
---|---|---|
committer | tb <> | 2024-11-05 18:20:08 +0000 |
commit | 5737d0f009803326f24baddb5d0ae6495f069273 (patch) | |
tree | f0d5a155498b0086ca8ddfab39969fc20d60127a | |
parent | 43968ec138d6f756dd8a78cbe9f27496b4ce45c5 (diff) | |
download | openbsd-5737d0f009803326f24baddb5d0ae6495f069273.tar.gz openbsd-5737d0f009803326f24baddb5d0ae6495f069273.tar.bz2 openbsd-5737d0f009803326f24baddb5d0ae6495f069273.zip |
bn_convert: avoid a zero-sized allocation
-rw-r--r-- | src/regress/lib/libcrypto/bn/bn_convert.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_convert.c b/src/regress/lib/libcrypto/bn/bn_convert.c index e7d6138f36..d122915667 100644 --- a/src/regress/lib/libcrypto/bn/bn_convert.c +++ b/src/regress/lib/libcrypto/bn/bn_convert.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_convert.c,v 1.8 2024/11/03 12:47:49 jsing Exp $ */ | 1 | /* $OpenBSD: bn_convert.c,v 1.9 2024/11/05 18:20:08 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -55,7 +55,7 @@ check_bin_output(size_t test_no, const char *label, const uint8_t *bin, | |||
55 | "want %zu\n", test_no, label, out_len, bin_len); | 55 | "want %zu\n", test_no, label, out_len, bin_len); |
56 | goto failure; | 56 | goto failure; |
57 | } | 57 | } |
58 | if ((out = malloc(out_len)) == NULL) | 58 | if (out_len > 0 && (out = malloc(out_len)) == NULL) |
59 | err(1, "malloc"); | 59 | err(1, "malloc"); |
60 | if ((ret = BN_bn2bin(bn, out)) != out_len) { | 60 | if ((ret = BN_bn2bin(bn, out)) != out_len) { |
61 | fprintf(stderr, "FAIL: Test %zu %s - BN_bn2bin() returned %d, " | 61 | fprintf(stderr, "FAIL: Test %zu %s - BN_bn2bin() returned %d, " |