]> git.hungrycats.org Git - linux/commitdiff
NFSv4: Bugfixes for the NFSv4 client name to uid mapper.
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 7 Feb 2004 15:27:44 +0000 (16:27 +0100)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 7 Feb 2004 15:27:44 +0000 (16:27 +0100)
Fixes a memory-scribble problem.

fs/nfs/idmap.c
fs/nfs/nfs4xdr.c

index f984e0156fa2bd91916f57b32362200e18301db7..155eb0debd83574b74bb7733213c4148822459f1 100644 (file)
@@ -146,7 +146,8 @@ nfs_idmap_id(struct nfs_server *server, u_int8_t type, char *name,
        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, u_int8_t type, char *name,
 
        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;
index 1ff99644aa498686883960871464f54474469e77..f2a909d75468c7518f16b0bccccd2e0003bb43c1 100644 (file)
@@ -241,8 +241,8 @@ encode_attrs(struct xdr_stream *xdr, struct iattr *iap,
 {
        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, struct nfs4_getattr *getattr,
                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, struct nfs4_getattr *getattr,
                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; */