From: Arran Cudbard-Bell Date: Tue, 22 Feb 2022 21:46:54 +0000 (-0500) Subject: use all pre-allocated MD5 ctxs to reduce OpenSSL malloc/free noise X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=002df76df47c9276c46c0b5da2dab84df8e484b5;p=thirdparty%2Ffreeradius-server.git use all pre-allocated MD5 ctxs to reduce OpenSSL malloc/free noise --- diff --git a/src/protocols/radius/decode.c b/src/protocols/radius/decode.c index 9879186dca1..085cfcd06ed 100644 --- a/src/protocols/radius/decode.c +++ b/src/protocols/radius/decode.c @@ -101,7 +101,7 @@ ssize_t fr_radius_decode_tunnel_password(uint8_t *passwd, size_t *pwlen, */ secretlen = talloc_array_length(secret) - 1; - md5_ctx = fr_md5_ctx_alloc(false); + md5_ctx = fr_md5_ctx_alloc(true); md5_ctx_old = fr_md5_ctx_alloc(true); fr_md5_update(md5_ctx, (uint8_t const *) secret, secretlen); @@ -212,7 +212,7 @@ ssize_t fr_radius_decode_password(char *passwd, size_t pwlen, char const *secret */ secretlen = talloc_array_length(secret) - 1; - md5_ctx = fr_md5_ctx_alloc(false); + md5_ctx = fr_md5_ctx_alloc(true); md5_ctx_old = fr_md5_ctx_alloc(true); fr_md5_update(md5_ctx, (uint8_t const *) secret, secretlen); diff --git a/src/protocols/radius/encode.c b/src/protocols/radius/encode.c index 7a0dc35d54e..665e5f2b317 100644 --- a/src/protocols/radius/encode.c +++ b/src/protocols/radius/encode.c @@ -98,7 +98,7 @@ static ssize_t encode_password(fr_dbuff_t *dbuff, fr_dbuff_marker_t *input, size len &= ~0x0f; } - md5_ctx = fr_md5_ctx_alloc(false); + md5_ctx = fr_md5_ctx_alloc(true); md5_ctx_old = fr_md5_ctx_alloc(true); fr_md5_update(md5_ctx, (uint8_t const *) secret, talloc_array_length(secret) - 1); @@ -198,7 +198,7 @@ static ssize_t encode_tunnel_password(fr_dbuff_t *dbuff, fr_dbuff_marker_t *in, tpasswd[1] = r & 0xff; tpasswd[2] = inlen; /* length of the password string */ - md5_ctx = fr_md5_ctx_alloc(false); + md5_ctx = fr_md5_ctx_alloc(true); md5_ctx_old = fr_md5_ctx_alloc(true); fr_md5_update(md5_ctx, (uint8_t const *) packet_ctx->secret, talloc_array_length(packet_ctx->secret) - 1);