From e7a27b19758a156e2605a97d97b417e881d5af29 Mon Sep 17 00:00:00 2001 From: DiamondGotCat Date: Sat, 7 Jun 2025 07:01:55 +0900 Subject: [PATCH] keys: ecryptfs: null-terminate password signature --- security/keys/encrypted-keys/ecryptfs_format.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/keys/encrypted-keys/ecryptfs_format.c b/security/keys/encrypted-keys/ecryptfs_format.c index 8fdd76105ce343..c97917831a3ad0 100644 --- a/security/keys/encrypted-keys/ecryptfs_format.c +++ b/security/keys/encrypted-keys/ecryptfs_format.c @@ -56,6 +56,8 @@ int ecryptfs_fill_auth_tok(struct ecryptfs_auth_tok *auth_tok, auth_tok->token_type = ECRYPTFS_PASSWORD; strncpy((char *)auth_tok->token.password.signature, key_desc, ECRYPTFS_PASSWORD_SIG_SIZE); + /* Ensure signature string is null terminated as strncpy may not */ + auth_tok->token.password.signature[ECRYPTFS_PASSWORD_SIG_SIZE] = '\0'; auth_tok->token.password.session_key_encryption_key_bytes = ECRYPTFS_MAX_KEY_BYTES; /*