[3/3] NFS: Ensure cached readdir info is NUL terminated
diff mbox series

Message ID 20190706185252.32488-3-trond.myklebust@hammerspace.com
State New
Headers show
Series
  • [1/3] NFS: Fix off-by-one errors in nfs_readdir
Related show

Commit Message

Trond Myklebust July 6, 2019, 6:52 p.m. UTC
Strictly speaking, struct qstr does not require a NUL terminated string,
but in practice all dentries are deliberately stored that way.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 6ccf0e6c9c84..7313084424bb 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -189,7 +189,7 @@  static
 int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int len)
 {
 	string->len = len;
-	string->name = kmemdup(name, len, GFP_KERNEL);
+	string->name = kmemdup_nul(name, len, GFP_KERNEL);;
 	if (string->name == NULL)
 		return -ENOMEM;
 	/*