]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nfs: Avoid overrun when copying client IP address string
authorBen Hutchings <ben@decadent.org.uk>
Tue, 6 Oct 2009 19:42:18 +0000 (15:42 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 6 Oct 2009 19:42:18 +0000 (15:42 -0400)
As seen in <http://bugs.debian.org/549002>, nfs4_init_client() can
overrun the source string when copying the client IP address from
nfs_parsed_mount_data::client_address to nfs_client::cl_ipaddr.  Since
these are both treated as null-terminated strings elsewhere, the copy
should be done with strlcpy() not memcpy().

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/client.c

index 63976c0ccc2539d72155d11613fbaa9322358afb..99ea196f071f04d81c82fbc42bdcb000b9f0694d 100644 (file)
@@ -1180,7 +1180,7 @@ static int nfs4_init_client(struct nfs_client *clp,
                                      1, flags & NFS_MOUNT_NORESVPORT);
        if (error < 0)
                goto error;
-       memcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
+       strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
 
        error = nfs_idmap_new(clp);
        if (error < 0) {