Skip to content

Commit

Permalink
vfs: introduce helper function to safely NUL-terminate symlinks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Duane Griffin authored and Al Viro committed Dec 31, 2008
1 parent a17d523 commit 0351468
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/linux/namei.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 0351468

Please sign in to comment.