From: Duane Griffin Date: Fri, 19 Dec 2008 20:47:11 +0000 (+0000) Subject: vfs: introduce helper function to safely NUL-terminate symlinks X-Git-Tag: v2.6.29-rc1~549^2~27 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=035146851cfa2fe24c1d9dc7637bb009ad06b2f7;p=linux-2.6-omap-h63xx.git 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 Cc: Andrew Morton Signed-off-by: Duane Griffin Signed-off-by: Al Viro --- diff --git a/include/linux/namei.h b/include/linux/namei.h index 99eb80306dc..fc2e0357987 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -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 */