Skip to content

Commit 0351468

Browse files
duanegAl Viro
authored andcommitted
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>
1 parent a17d523 commit 0351468

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎include/linux/namei.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,9 @@ static inline char *nd_get_link(struct nameidata *nd)
9494
return nd->saved_names[nd->depth];
9595
}
9696

97+
static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
98+
{
99+
((char *) name)[min(len, maxlen)] = '\0';
100+
}
101+
97102
#endif /* _LINUX_NAMEI_H */

0 commit comments

Comments
 (0)