aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/namei.h
diff options
context:
space:
mode:
authorDuane Griffin <duaneg@dghda.com>2008-12-19 15:47:11 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2008-12-31 18:07:38 -0500
commit035146851cfa2fe24c1d9dc7637bb009ad06b2f7 (patch)
treeb6dd89c60a2100e1c0c48abd1688d3d2ff5f5607 /include/linux/namei.h
parenta17d5232de7b53d34229de79ec22f4bb04adb7e4 (diff)
vfs: introduce helper function to safely NUL-terminate symlinks
A number of filesystems were potentially triggering kernel bugs due to corrupted symlink names on disk. This function helps safely terminate the names. Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Duane Griffin <duaneg@dghda.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/namei.h')
-rw-r--r--include/linux/namei.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 99eb80306dc5..fc2e03579877 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -94,4 +94,9 @@ static inline char *nd_get_link(struct nameidata *nd)
94 return nd->saved_names[nd->depth]; 94 return nd->saved_names[nd->depth];
95} 95}
96 96
97static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
98{
99 ((char *) name)[min(len, maxlen)] = '\0';
100}
101
97#endif /* _LINUX_NAMEI_H */ 102#endif /* _LINUX_NAMEI_H */