From: Eugene Syromiatnikov Date: Thu, 17 Jul 2025 11:21:33 +0000 (+0200) Subject: crypto/ec/ecp_nistp256.c: use OPENSSL_zalloc instead of malloc+memset X-Git-Tag: openssl-3.6.0-alpha1~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f859bb5927632c823f08fe5f48239149aa4cdea;p=thirdparty%2Fopenssl.git crypto/ec/ecp_nistp256.c: use OPENSSL_zalloc instead of malloc+memset Complements: b51bce942023 "Add and use OPENSSL_zalloc" Signed-off-by: Eugene Syromiatnikov Reviewed-by: Saša Nedvědický Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28059) --- diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index eaf9dddbc8e..9c850f644f6 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -2088,8 +2088,8 @@ int ossl_ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, */ mixed = 1; } - secrets = OPENSSL_malloc(sizeof(*secrets) * num_points); - pre_comp = OPENSSL_malloc(sizeof(*pre_comp) * num_points); + secrets = OPENSSL_zalloc(sizeof(*secrets) * num_points); + pre_comp = OPENSSL_zalloc(sizeof(*pre_comp) * num_points); if (mixed) tmp_smallfelems = OPENSSL_malloc(sizeof(*tmp_smallfelems) * (num_points * 17 + 1)); @@ -2101,8 +2101,6 @@ int ossl_ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, * we treat NULL scalars as 0, and NULL points as points at infinity, * i.e., they contribute nothing to the linear combination */ - memset(secrets, 0, sizeof(*secrets) * num_points); - memset(pre_comp, 0, sizeof(*pre_comp) * num_points); for (i = 0; i < num_points; ++i) { if (i == num) { /*