Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ecryptfs: Replace memcpy + manual NUL termination with strscpy

Use strscpy() to copy the NUL-terminated '->token.password.signature'
and 'sig' to the destination buffers instead of using memcpy() followed
by manual NUL terminations.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Tyler Hicks <code@tyhicks.com>

authored by

Thorsten Blum and committed by
Tyler Hicks
f7a1c028 7d9ebf33

+4 -7
+2 -3
fs/ecryptfs/debug.c
··· 7 7 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> 8 8 */ 9 9 10 + #include <linux/string.h> 10 11 #include "ecryptfs_kernel.h" 11 12 12 13 /* ··· 34 33 ECRYPTFS_PERSISTENT_PASSWORD) { 35 34 ecryptfs_printk(KERN_DEBUG, " * persistent\n"); 36 35 } 37 - memcpy(sig, auth_tok->token.password.signature, 38 - ECRYPTFS_SIG_SIZE_HEX); 39 - sig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; 36 + strscpy(sig, auth_tok->token.password.signature); 40 37 ecryptfs_printk(KERN_DEBUG, " * signature = [%s]\n", sig); 41 38 } 42 39 ecryptfs_printk(KERN_DEBUG, " * session_key.flags = [0x%x]\n",
+2 -4
fs/ecryptfs/keystore.c
··· 2458 2458 if (!new_key_sig) 2459 2459 return -ENOMEM; 2460 2460 2461 - memcpy(new_key_sig->keysig, sig, ECRYPTFS_SIG_SIZE_HEX); 2462 - new_key_sig->keysig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; 2461 + strscpy(new_key_sig->keysig, sig); 2463 2462 /* Caller must hold keysig_list_mutex */ 2464 2463 list_add(&new_key_sig->crypt_stat_list, &crypt_stat->keysig_list); 2465 2464 ··· 2478 2479 if (!new_auth_tok) 2479 2480 return -ENOMEM; 2480 2481 2481 - memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX); 2482 + strscpy(new_auth_tok->sig, sig); 2482 2483 new_auth_tok->flags = global_auth_tok_flags; 2483 - new_auth_tok->sig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; 2484 2484 mutex_lock(&mount_crypt_stat->global_auth_tok_list_mutex); 2485 2485 list_add(&new_auth_tok->mount_crypt_stat_list, 2486 2486 &mount_crypt_stat->global_auth_tok_list);