From: Tyler Hicks <code@tyhicks.com>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Christian Brauner <brauner@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
Eric Biggers <ebiggers@kernel.org>,
ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] ecryptfs: Replace memcpy + NUL termination in ecryptfs_new_file_context
Date: Tue, 23 Dec 2025 14:28:33 -0600 [thread overview]
Message-ID: <aUr7cX-QULAhQ1oF@yaupon> (raw)
In-Reply-To: <20251219213235.71774-1-thorsten.blum@linux.dev>
On 2025-12-19 22:32:33, Thorsten Blum wrote:
> Use strscpy() to copy the NUL-terminated '->global_default_cipher_name'
> to the destination buffer instead of using memcpy() followed by a manual
> NUL termination. Remove the now-unused local variable 'cipher_name_len'.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Thanks for the cleanup!
Acked-by: Tyler Hicks <code@tyhicks.com>
Tyler
> ---
> fs/ecryptfs/crypto.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 260f8a4938b0..5d9ec4a1e12d 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -678,7 +678,6 @@ int ecryptfs_new_file_context(struct inode *ecryptfs_inode)
> struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
> &ecryptfs_superblock_to_private(
> ecryptfs_inode->i_sb)->mount_crypt_stat;
> - int cipher_name_len;
> int rc = 0;
>
> ecryptfs_set_default_crypt_stat_vals(crypt_stat, mount_crypt_stat);
> @@ -692,12 +691,8 @@ int ecryptfs_new_file_context(struct inode *ecryptfs_inode)
> "to the inode key sigs; rc = [%d]\n", rc);
> goto out;
> }
> - cipher_name_len =
> - strlen(mount_crypt_stat->global_default_cipher_name);
> - memcpy(crypt_stat->cipher,
> - mount_crypt_stat->global_default_cipher_name,
> - cipher_name_len);
> - crypt_stat->cipher[cipher_name_len] = '\0';
> + strscpy(crypt_stat->cipher,
> + mount_crypt_stat->global_default_cipher_name);
> crypt_stat->key_size =
> mount_crypt_stat->global_default_cipher_key_size;
> ecryptfs_generate_new_key(crypt_stat);
> --
> Thorsten Blum <thorsten.blum@linux.dev>
> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
>
prev parent reply other threads:[~2025-12-23 20:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 21:32 [PATCH RESEND] ecryptfs: Replace memcpy + NUL termination in ecryptfs_new_file_context Thorsten Blum
2025-12-23 20:28 ` Tyler Hicks [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aUr7cX-QULAhQ1oF@yaupon \
--to=code@tyhicks.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=ebiggers@kernel.org \
--cc=ecryptfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.