[PATCH] ufs: ensure fast symlinks are NUL-terminated

From: Duane Griffin
Date: Tue Dec 16 2008 - 10:54:51 EST


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

Cc: Evgeniy Dushistov <dushistov@xxxxxxx>
Signed-off-by: Duane Griffin <duaneg@xxxxxxxxx>
---
fs/ufs/inode.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 39f8778..aca4b58 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -36,6 +36,7 @@
#include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/buffer_head.h>
+#include <linux/namei.h>

#include "ufs_fs.h"
#include "ufs.h"
@@ -606,9 +607,12 @@ static void ufs_set_inode_ops(struct inode *inode)
inode->i_fop = &ufs_dir_operations;
inode->i_mapping->a_ops = &ufs_aops;
} else if (S_ISLNK(inode->i_mode)) {
- if (!inode->i_blocks)
+ if (!inode->i_blocks) {
inode->i_op = &ufs_fast_symlink_inode_operations;
- else {
+ nd_terminate_link(UFS_I(inode)->i_u1.i_symlink,
+ inode->i_size,
+ sizeof(UFS_I(inode)->i_u1.i_symlink));
+ } else {
inode->i_op = &page_symlink_inode_operations;
inode->i_mapping->a_ops = &ufs_aops;
}
--
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/