diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-10-25 00:37:52 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-10-25 00:37:52 +0000 |
commit | 917f452a13a6c4e4c05d794f117c72753e7ccd10 (patch) | |
tree | 991f5bd79287399fe6790055c9e8df26e2fb00eb | |
parent | c0abffdeb0a67a408759598c2448b0636e190a73 (diff) |
Minor cosmetic tweaks for EC_GROUP_set_seed()
No need to guard free() with a NULL check, check explicitly against 0
and rename p to seed.
-rw-r--r-- | lib/libcrypto/ec/ec_lib.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 6da20266622..0dcee7b2783 100644 --- a/lib/libcrypto/ec/ec_lib.c +++ b/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.73 2024/10/22 12:06:08 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.74 2024/10/25 00:37:51 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -452,19 +452,18 @@ EC_GROUP_get_point_conversion_form(const EC_GROUP *group) LCRYPTO_ALIAS(EC_GROUP_get_point_conversion_form); size_t -EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len) +EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *seed, size_t len) { - if (group->seed) { - free(group->seed); - group->seed = NULL; - group->seed_len = 0; - } - if (!len || !p) + free(group->seed); + group->seed = NULL; + group->seed_len = 0; + + if (len == 0 || seed == NULL) return 1; if ((group->seed = malloc(len)) == NULL) return 0; - memcpy(group->seed, p, len); + memcpy(group->seed, seed, len); group->seed_len = len; return len; |