diff mbox

Ensure user-supplied string null terminated before kstrdup()

Message ID 4D4B287E.70206@parallels.com (mailing list archive)
State Rejected, archived
Delegated to: Trond Myklebust
Headers show

Commit Message

Rob Landley Feb. 3, 2011, 10:13 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b68c860..0ad1255 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1881,9 +1881,12 @@  static int nfs_validate_mount_data(void *options,
 
 		if (!(data->flags & NFS_MOUNT_TCP))
 			args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
+		/* Force null termination of data->hostname no matter what
+		   user passed in. */
+		args->namlen		= data->namlen;
+		data->namlen = 0;
 		/* N.B. caller will free nfs_server.hostname in all cases */
 		args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
-		args->namlen		= data->namlen;
 		args->bsize		= data->bsize;
 
 		if (data->flags & NFS_MOUNT_SECFLAVOUR)