Commit 674b2222920012244ca59978b356b25412a8dcc7
Committed by
Trond Myklebust
1 parent
a2dccdb205
Exists in
master
and in
7 other branches
nfs: include space for the NUL in root path
In root_nfs_name() it does the following: if (strlen(buf) + strlen(cp) > NFS_MAXPATHLEN) { printk(KERN_ERR "Root-NFS: Pathname for remote directory too long.\n"); return -1; } sprintf(nfs_export_path, buf, cp); In the original code if (strlen(buf) + strlen(cp) == NFS_MAXPATHLEN) then the sprintf() would lead to an overflow. Generally the rest of the code assumes that the path can have NFS_MAXPATHLEN (1024) characters and a NUL terminator so the fix is to add space to the nfs_export_path[] buffer. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
fs/nfs/nfsroot.c
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | static __be32 servaddr __initdata = 0; |
106 | 106 | |
107 | 107 | /* Name of directory to mount */ |
108 | -static char nfs_export_path[NFS_MAXPATHLEN] __initdata = { 0, }; | |
108 | +static char nfs_export_path[NFS_MAXPATHLEN + 1] __initdata = { 0, }; | |
109 | 109 | |
110 | 110 | /* NFS-related data */ |
111 | 111 | static struct nfs_mount_data nfs_data __initdata = { 0, };/* NFS mount info */ |