From: Trond Myklebust <trond.myklebust@fys.uio.no>

NFSv4: Bugfixes for the NFSv4 client name to uid mapper. Fixes a memory-scribble problem.


---

 fs/nfs/idmap.c   |   12 ++----------
 fs/nfs/nfs4xdr.c |    8 ++++----
 2 files changed, 6 insertions(+), 14 deletions(-)

diff -puN fs/nfs/idmap.c~nfs-05-fix_idmap fs/nfs/idmap.c
--- 25/fs/nfs/idmap.c~nfs-05-fix_idmap	2004-01-09 22:16:11.000000000 -0800
+++ 25-akpm/fs/nfs/idmap.c	2004-01-09 22:16:11.000000000 -0800
@@ -146,7 +146,8 @@ nfs_idmap_id(struct nfs_server *server, 
 	struct idmap *idmap = server->idmap;
 	struct idmap_msg *im;
 	DECLARE_WAITQUEUE(wq, current);
-	int ret = -1, hashtype = IDMAP_HASH_TYPE_NAME, xnamelen = namelen;
+	int ret = -1, hashtype = IDMAP_HASH_TYPE_NAME;
+	u_int xnamelen = namelen;
 
 	if (idmap == NULL)
 		return (-1);
@@ -169,15 +170,6 @@ nfs_idmap_id(struct nfs_server *server, 
 
 	memset(im, 0, sizeof(*im));
 	memcpy(im->im_name, name, namelen);
-	/* Make sure the string is NULL terminated */
-	if (namelen != xnamelen) {
-		/* We cannot fit a NULL character */
-		if (namelen == IDMAP_NAMESZ) {
-			ret = -1;
-			goto out;
-		}
-		im->im_name[namelen] = '\0';
-	} 
 
 	im->im_type = type;
 	im->im_conv = IDMAP_CONV_NAMETOID;
diff -puN fs/nfs/nfs4xdr.c~nfs-05-fix_idmap fs/nfs/nfs4xdr.c
--- 25/fs/nfs/nfs4xdr.c~nfs-05-fix_idmap	2004-01-09 22:16:11.000000000 -0800
+++ 25-akpm/fs/nfs/nfs4xdr.c	2004-01-09 22:16:11.000000000 -0800
@@ -241,8 +241,8 @@ encode_attrs(struct xdr_stream *xdr, str
 {
 	char owner_name[256];
 	char owner_group[256];
-	int owner_namelen = 0;
-	int owner_grouplen = 0;
+	int owner_namelen = sizeof(owner_name);
+	int owner_grouplen = sizeof(owner_group);
 	uint32_t *p;
 	uint32_t *q;
 	int len;
@@ -1476,7 +1476,7 @@ decode_getattr(struct xdr_stream *xdr, s
 		READ_BUF(dummy32);
 		len += (XDR_QUADLEN(dummy32) << 2);
 		if ((status = nfs_idmap_id(server, IDMAP_TYPE_USER,
-			 (char *)p, len, &nfp->uid)) == -1) {
+			 (char *)p, dummy32, &nfp->uid)) == -1) {
 			dprintk("read_attrs: gss_get_num failed!\n");
 			/* goto out; */
 			nfp->uid = -2;
@@ -1494,7 +1494,7 @@ decode_getattr(struct xdr_stream *xdr, s
 		READ_BUF(dummy32);
 		len += (XDR_QUADLEN(dummy32) << 2);
 		if ((status = nfs_idmap_id(server, IDMAP_TYPE_GROUP,
-			 (char *)p, len, &nfp->gid)) == -1) {
+			 (char *)p, dummy32, &nfp->gid)) == -1) {
 			dprintk("read_attrs: gss_get_num failed!\n");
 			nfp->gid = -2;
 			/* goto out; */

_