From 3f6cdd7aab90fa6b4830349916d994a05d6f8f79 Mon Sep 17 00:00:00 2001 From: Raef Coles Date: Fri, 7 Oct 2022 14:07:59 +0100 Subject: [PATCH] Fix LMS not checking RNG function return value Signed-off-by: Raef Coles --- library/lms.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/library/lms.c b/library/lms.c index 1e0f319109..a4235addc2 100644 --- a/library/lms.c +++ b/library/lms.c @@ -545,9 +545,13 @@ int mbedtls_lms_generate_private_key( mbedtls_lms_private_t *ctx, ctx->params.type = type; ctx->params.otstype = otstype; - f_rng( p_rng, - ctx->params.I_key_identifier, - MBEDTLS_LMOTS_I_KEY_ID_LEN ); + ret = f_rng( p_rng, + ctx->params.I_key_identifier, + MBEDTLS_LMOTS_I_KEY_ID_LEN ); + if( ret != 0 ) + { + goto exit; + } ctx->ots_private_keys = mbedtls_calloc( ( size_t )MERKLE_TREE_LEAF_NODE_AM(ctx->params.type), sizeof( *ctx->ots_private_keys ) );