NFS: Use kmemdup_nul() in nfs_readdir_make_qstr()
authorTrond Myklebust <trondmy@gmail.com>
Sun, 2 Feb 2020 22:53:55 +0000 (17:53 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 3 Feb 2020 21:37:45 +0000 (16:37 -0500)
The directory strings stored in the readdir cache may be used with
printk(), so it is better to ensure they are nul-terminated.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/dir.c

index d95c2c94bd8764229669af8082451468d84881e8..5a8ff7e97ce34a611430cf723d86e0674930cc9f 100644 (file)
@@ -198,7 +198,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;
        /*