]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
vfs: introduce helper function to safely NUL-terminate symlinks
authorDuane Griffin <duaneg@dghda.com>
Fri, 19 Dec 2008 20:47:11 +0000 (20:47 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 31 Dec 2008 23:07:38 +0000 (18:07 -0500)
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>
include/linux/namei.h

index 99eb80306dc5bba4fab74b9a1693222209d619ea..fc2e035798776a5f65a813a4c1cf55778d2d700e 100644 (file)
@@ -94,4 +94,9 @@ static inline char *nd_get_link(struct nameidata *nd)
        return nd->saved_names[nd->depth];
 }
 
+static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
+{
+       ((char *) name)[min(len, maxlen)] = '\0';
+}
+
 #endif /* _LINUX_NAMEI_H */