Skip to content

Commit

Permalink
nfs: include space for the NUL in root path
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
error27 authored and Trond Myklebust committed Jul 30, 2010
1 parent a2dccdb commit 674b222
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/nfs/nfsroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static char nfs_root_name[256] __initdata = "";
static __be32 servaddr __initdata = 0;

/* Name of directory to mount */
static char nfs_export_path[NFS_MAXPATHLEN] __initdata = { 0, };
static char nfs_export_path[NFS_MAXPATHLEN + 1] __initdata = { 0, };

/* NFS-related data */
static struct nfs_mount_data nfs_data __initdata = { 0, };/* NFS mount info */
Expand Down

0 comments on commit 674b222

Please sign in to comment.