mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
ext4: use memcpy() instead of strcpy()
The strcpy() function is considered dangerous and eeeevil by people
who are using sophisticated code analysis tools such as "grep". This
is true even when a quick inspection would show that the source is a
constant string ("." or "..") and the destination is a fixed array
which is guaranteed to have enough space. Make the "grep" code
analysis tool happy by using memcpy() isstead of strcpy(). :-)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Link: https://patch.msgid.link/20250712181249.434530-2-tytso@mit.edu
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
3658b8b339
commit
a35454ecf8
|
|
@ -1317,7 +1317,7 @@ int ext4_inlinedir_to_tree(struct file *dir_file,
|
|||
if (pos == 0) {
|
||||
fake.inode = cpu_to_le32(inode->i_ino);
|
||||
fake.name_len = 1;
|
||||
strcpy(fake.name, ".");
|
||||
memcpy(fake.name, ".", 2);
|
||||
fake.rec_len = ext4_rec_len_to_disk(
|
||||
ext4_dir_rec_len(fake.name_len, NULL),
|
||||
inline_size);
|
||||
|
|
@ -1327,7 +1327,7 @@ int ext4_inlinedir_to_tree(struct file *dir_file,
|
|||
} else if (pos == EXT4_INLINE_DOTDOT_OFFSET) {
|
||||
fake.inode = cpu_to_le32(parent_ino);
|
||||
fake.name_len = 2;
|
||||
strcpy(fake.name, "..");
|
||||
memcpy(fake.name, "..", 3);
|
||||
fake.rec_len = ext4_rec_len_to_disk(
|
||||
ext4_dir_rec_len(fake.name_len, NULL),
|
||||
inline_size);
|
||||
|
|
|
|||
|
|
@ -2924,7 +2924,7 @@ struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
|
|||
de->name_len = 1;
|
||||
de->rec_len = ext4_rec_len_to_disk(ext4_dir_rec_len(de->name_len, NULL),
|
||||
blocksize);
|
||||
strcpy(de->name, ".");
|
||||
memcpy(de->name, ".", 2);
|
||||
ext4_set_de_type(inode->i_sb, de, S_IFDIR);
|
||||
|
||||
de = ext4_next_entry(de, blocksize);
|
||||
|
|
@ -2938,7 +2938,7 @@ struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
|
|||
de->rec_len = ext4_rec_len_to_disk(
|
||||
ext4_dir_rec_len(de->name_len, NULL),
|
||||
blocksize);
|
||||
strcpy(de->name, "..");
|
||||
memcpy(de->name, "..", 3);
|
||||
ext4_set_de_type(inode->i_sb, de, S_IFDIR);
|
||||
|
||||
return ext4_next_entry(de, blocksize);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user