]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ufs: ensure fast symlinks are NUL-terminated
authorDuane Griffin <duaneg@dghda.com>
Thu, 8 Jan 2009 22:43:50 +0000 (22:43 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 27 Mar 2009 18:43:58 +0000 (14:43 -0400)
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>
fs/ufs/inode.c

index ac8b324415d31fbfa385bf1d21169ca40e10ecb8..3d2512c21f05c7d6ade3f2b64f2231f9b924c94d 100644 (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));
        } else {
                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;
 }
@@ -706,7 +707,8 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
                       sizeof(ufs2_inode->ui_u2.ui_addr));
        } else {
                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;
 }