public inbox for ecryptfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ecryptfs: Drop redundant NUL terminations after calling ecryptfs_to_hex
@ 2025-11-20 22:17 Thorsten Blum
  2025-12-23 20:54 ` Tyler Hicks
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-11-20 22:17 UTC (permalink / raw)
  To: Tyler Hicks, Ard Biesheuvel, Christian Brauner, Eric Biggers
  Cc: Thorsten Blum, ecryptfs, linux-kernel

ecryptfs_to_hex() already NUL-terminates the destination buffers. Drop
the manual NUL terminations.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Remove all redundant NUL terminations after calling ecryptfs_to_hex
- Link to v1: https://lore.kernel.org/lkml/20251120214535.5952-2-thorsten.blum@linux.dev/
---
 fs/ecryptfs/debug.c    | 1 -
 fs/ecryptfs/keystore.c | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/fs/ecryptfs/debug.c b/fs/ecryptfs/debug.c
index cf6d0e8e25a1..c185a8cb5fe2 100644
--- a/fs/ecryptfs/debug.c
+++ b/fs/ecryptfs/debug.c
@@ -28,7 +28,6 @@ void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
 		ecryptfs_printk(KERN_DEBUG, " * passphrase type\n");
 		ecryptfs_to_hex(salt, auth_tok->token.password.salt,
 				ECRYPTFS_SALT_SIZE);
-		salt[ECRYPTFS_SALT_SIZE * 2] = '\0';
 		ecryptfs_printk(KERN_DEBUG, " * salt = [%s]\n", salt);
 		if (auth_tok->token.password.flags &
 		    ECRYPTFS_PERSISTENT_PASSWORD) {
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 3a6283477d61..9f53069bbc7c 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -908,7 +908,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
 	(*packet_size) += s->packet_size_len;
 	ecryptfs_to_hex(s->fnek_sig_hex, &data[(*packet_size)],
 			ECRYPTFS_SIG_SIZE);
-	s->fnek_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
 	(*packet_size) += ECRYPTFS_SIG_SIZE;
 	s->cipher_code = data[(*packet_size)++];
 	rc = ecryptfs_cipher_code_to_string(s->cipher_string, s->cipher_code);
@@ -1777,8 +1776,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
 			}
 			ecryptfs_to_hex(new_auth_tok->token.password.signature,
 					sig_tmp_space, tag_11_contents_size);
-			new_auth_tok->token.password.signature[
-				ECRYPTFS_PASSWORD_SIG_SIZE] = '\0';
 			crypt_stat->flags |= ECRYPTFS_ENCRYPTED;
 			break;
 		case ECRYPTFS_TAG_1_PACKET_TYPE:
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ecryptfs: Drop redundant NUL terminations after calling ecryptfs_to_hex
  2025-11-20 22:17 [PATCH v2] ecryptfs: Drop redundant NUL terminations after calling ecryptfs_to_hex Thorsten Blum
@ 2025-12-23 20:54 ` Tyler Hicks
  0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2025-12-23 20:54 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Ard Biesheuvel, Christian Brauner, Eric Biggers, ecryptfs,
	linux-kernel

On 2025-11-20 23:17:57, Thorsten Blum wrote:
> ecryptfs_to_hex() already NUL-terminates the destination buffers. Drop
> the manual NUL terminations.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Thanks again for the cleanup!

Acked-by: Tyler Hicks <code@tyhicks.com>

Tyler

> ---
> Changes in v2:
> - Remove all redundant NUL terminations after calling ecryptfs_to_hex
> - Link to v1: https://lore.kernel.org/lkml/20251120214535.5952-2-thorsten.blum@linux.dev/
> ---
>  fs/ecryptfs/debug.c    | 1 -
>  fs/ecryptfs/keystore.c | 3 ---
>  2 files changed, 4 deletions(-)
> 
> diff --git a/fs/ecryptfs/debug.c b/fs/ecryptfs/debug.c
> index cf6d0e8e25a1..c185a8cb5fe2 100644
> --- a/fs/ecryptfs/debug.c
> +++ b/fs/ecryptfs/debug.c
> @@ -28,7 +28,6 @@ void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
>  		ecryptfs_printk(KERN_DEBUG, " * passphrase type\n");
>  		ecryptfs_to_hex(salt, auth_tok->token.password.salt,
>  				ECRYPTFS_SALT_SIZE);
> -		salt[ECRYPTFS_SALT_SIZE * 2] = '\0';
>  		ecryptfs_printk(KERN_DEBUG, " * salt = [%s]\n", salt);
>  		if (auth_tok->token.password.flags &
>  		    ECRYPTFS_PERSISTENT_PASSWORD) {
> diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
> index 3a6283477d61..9f53069bbc7c 100644
> --- a/fs/ecryptfs/keystore.c
> +++ b/fs/ecryptfs/keystore.c
> @@ -908,7 +908,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
>  	(*packet_size) += s->packet_size_len;
>  	ecryptfs_to_hex(s->fnek_sig_hex, &data[(*packet_size)],
>  			ECRYPTFS_SIG_SIZE);
> -	s->fnek_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
>  	(*packet_size) += ECRYPTFS_SIG_SIZE;
>  	s->cipher_code = data[(*packet_size)++];
>  	rc = ecryptfs_cipher_code_to_string(s->cipher_string, s->cipher_code);
> @@ -1777,8 +1776,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
>  			}
>  			ecryptfs_to_hex(new_auth_tok->token.password.signature,
>  					sig_tmp_space, tag_11_contents_size);
> -			new_auth_tok->token.password.signature[
> -				ECRYPTFS_PASSWORD_SIG_SIZE] = '\0';
>  			crypt_stat->flags |= ECRYPTFS_ENCRYPTED;
>  			break;
>  		case ECRYPTFS_TAG_1_PACKET_TYPE:
> -- 
> 2.51.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-23 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 22:17 [PATCH v2] ecryptfs: Drop redundant NUL terminations after calling ecryptfs_to_hex Thorsten Blum
2025-12-23 20:54 ` Tyler Hicks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox