Skip to content

Commit

Permalink
nfs: Avoid overrun when copying client IP address string
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
bwhacks authored and Trond Myklebust committed Oct 6, 2009
1 parent bcd2ea1 commit f4373bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f4373bf

Please sign in to comment.