From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Duane Griffin" Subject: [PATCH, v5] vfs: introduce helper function to safely NUL-terminate symlinks Date: Fri, 19 Dec 2008 20:47:11 +0000 Message-ID: <1229719638-6982-4-git-send-email-duaneg@dghda.com> References: <1229719638-6982-1-git-send-email-duaneg@dghda.com> <1229719638-6982-2-git-send-email-duaneg@dghda.com> <1229719638-6982-3-git-send-email-duaneg@dghda.com> Cc: linux-fsdevel@vger.kernel.org, Al Viro , Andrew Morton , Duane Griffin To: linux-kernel@vger.kernel.org Return-path: Received: from kumera.dghda.com ([80.68.90.171]:35276 "EHLO kumera.dghda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbYLSUrb (ORCPT ); Fri, 19 Dec 2008 15:47:31 -0500 In-Reply-To: <1229719638-6982-3-git-send-email-duaneg@dghda.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- Unchanged from v4. include/linux/namei.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/linux/namei.h b/include/linux/namei.h index 99eb803..fc2e035 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 */ -- 1.6.0.4