From b246eeccc53d663640d763fe9f06baadf8c9883e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9=20BALP?= Date: Tue, 16 Jan 2024 22:32:07 +0100 Subject: [PATCH] Fix snprintf buffer length --- lib/fko_encryption.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fko_encryption.c b/lib/fko_encryption.c index e4549224..604841ab 100644 --- a/lib/fko_encryption.c +++ b/lib/fko_encryption.c @@ -314,11 +314,11 @@ gpg_encrypt(fko_ctx_t ctx, const char *enc_key) /* Make a bucket big enough to hold the enc msg + digest (plaintext) * and populate it appropriately. */ - plain = calloc(1, ctx->encoded_msg_len + ctx->digest_len + 2); + plain = calloc(1, pt_len); if(plain == NULL) return(FKO_ERROR_MEMORY_ALLOCATION); - pt_len = snprintf(plain, pt_len+1, "%s:%s", ctx->encoded_msg, ctx->digest); + pt_len = snprintf(plain, pt_len, "%s:%s", ctx->encoded_msg, ctx->digest); if(! is_valid_pt_msg_len(pt_len)) {