]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
NFSD: Full checking of authentication name
authorKinglong Mee <kinglongmee@gmail.com>
Tue, 2 Sep 2014 14:14:31 +0000 (22:14 +0800)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 3 Sep 2014 21:43:03 +0000 (17:43 -0400)
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4idmap.c

index dc948f667650f51419fbafdafe8383353b10fb66..e1b3d3d472da70d08f4392b01e206a0224d54767 100644 (file)
@@ -215,7 +215,8 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
        memset(&ent, 0, sizeof(ent));
 
        /* Authentication name */
-       if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
+       len = qword_get(&buf, buf1, PAGE_SIZE);
+       if (len <= 0 || len >= IDMAP_NAMESZ)
                goto out;
        memcpy(ent.authname, buf1, sizeof(ent.authname));
 
@@ -245,12 +246,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
        /* Name */
        error = -EINVAL;
        len = qword_get(&buf, buf1, PAGE_SIZE);
-       if (len < 0)
+       if (len < 0 || len >= IDMAP_NAMESZ)
                goto out;
        if (len == 0)
                set_bit(CACHE_NEGATIVE, &ent.h.flags);
-       else if (len >= IDMAP_NAMESZ)
-               goto out;
        else
                memcpy(ent.name, buf1, sizeof(ent.name));
        error = -ENOMEM;
@@ -259,15 +258,12 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
                goto out;
 
        cache_put(&res->h, cd);
-
        error = 0;
 out:
        kfree(buf1);
-
        return error;
 }
 
-
 static struct ent *
 idtoname_lookup(struct cache_detail *cd, struct ent *item)
 {
@@ -381,7 +377,8 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
        memset(&ent, 0, sizeof(ent));
 
        /* Authentication name */
-       if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
+       len = qword_get(&buf, buf1, PAGE_SIZE);
+       if (len <= 0 || len >= IDMAP_NAMESZ)
                goto out;
        memcpy(ent.authname, buf1, sizeof(ent.authname));
 
@@ -421,7 +418,6 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
        error = 0;
 out:
        kfree(buf1);
-
        return (error);
 }