2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-18 15:44:02 +08:00

ufs: ensure fast symlinks are NUL-terminated

Ensure fast symlink targets are NUL-terminated, even if corrupted
on-disk.

Signed-off-by: Duane Griffin <duaneg@dghda.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Duane Griffin 2009-01-08 22:43:50 +00:00 committed by Al Viro
parent f33219b7a9
commit b12903f138

View File

@ -658,7 +658,8 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
sizeof(ufs_inode->ui_u2.ui_addr)); sizeof(ufs_inode->ui_u2.ui_addr));
} else { } else {
memcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink, memcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink,
sizeof(ufs_inode->ui_u2.ui_symlink)); sizeof(ufs_inode->ui_u2.ui_symlink) - 1);
ufsi->i_u1.i_symlink[sizeof(ufs_inode->ui_u2.ui_symlink) - 1] = 0;
} }
return 0; return 0;
} }
@ -706,7 +707,8 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
sizeof(ufs2_inode->ui_u2.ui_addr)); sizeof(ufs2_inode->ui_u2.ui_addr));
} else { } else {
memcpy(ufsi->i_u1.i_symlink, ufs2_inode->ui_u2.ui_symlink, memcpy(ufsi->i_u1.i_symlink, ufs2_inode->ui_u2.ui_symlink,
sizeof(ufs2_inode->ui_u2.ui_symlink)); sizeof(ufs2_inode->ui_u2.ui_symlink) - 1);
ufsi->i_u1.i_symlink[sizeof(ufs2_inode->ui_u2.ui_symlink) - 1] = 0;
} }
return 0; return 0;
} }