Skip to content

Commit 7391928

Browse files
azeemshaikh38kees
authored andcommitted
befs: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated. In an effort to remove strlcpy() completely, replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP/linux#89 Signed-off-by: Azeem Shaikh <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2f088df commit 7391928

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/befs/btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
500500
goto error_alloc;
501501
}
502502

503-
strlcpy(keybuf, keystart, keylen + 1);
503+
strscpy(keybuf, keystart, keylen + 1);
504504
*value = fs64_to_cpu(sb, valarray[cur_key]);
505505
*keysize = keylen;
506506

fs/befs/linuxvfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
374374
if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){
375375
inode->i_size = 0;
376376
inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE;
377-
strlcpy(befs_ino->i_data.symlink, raw_inode->data.symlink,
377+
strscpy(befs_ino->i_data.symlink, raw_inode->data.symlink,
378378
BEFS_SYMLINK_LEN);
379379
} else {
380380
int num_blks;

0 commit comments

Comments
 (0)