Commit 13c82e8e authored by Kinglong Mee's avatar Kinglong Mee Committed by J. Bruce Fields

NFSD: Full checking of authentication name

Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 48c348b0
...@@ -215,7 +215,8 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen) ...@@ -215,7 +215,8 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
memset(&ent, 0, sizeof(ent)); memset(&ent, 0, sizeof(ent));
/* Authentication name */ /* 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; goto out;
memcpy(ent.authname, buf1, sizeof(ent.authname)); memcpy(ent.authname, buf1, sizeof(ent.authname));
...@@ -245,12 +246,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen) ...@@ -245,12 +246,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
/* Name */ /* Name */
error = -EINVAL; error = -EINVAL;
len = qword_get(&buf, buf1, PAGE_SIZE); len = qword_get(&buf, buf1, PAGE_SIZE);
if (len < 0) if (len < 0 || len >= IDMAP_NAMESZ)
goto out; goto out;
if (len == 0) if (len == 0)
set_bit(CACHE_NEGATIVE, &ent.h.flags); set_bit(CACHE_NEGATIVE, &ent.h.flags);
else if (len >= IDMAP_NAMESZ)
goto out;
else else
memcpy(ent.name, buf1, sizeof(ent.name)); memcpy(ent.name, buf1, sizeof(ent.name));
error = -ENOMEM; error = -ENOMEM;
...@@ -259,15 +258,12 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen) ...@@ -259,15 +258,12 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
goto out; goto out;
cache_put(&res->h, cd); cache_put(&res->h, cd);
error = 0; error = 0;
out: out:
kfree(buf1); kfree(buf1);
return error; return error;
} }
static struct ent * static struct ent *
idtoname_lookup(struct cache_detail *cd, struct ent *item) idtoname_lookup(struct cache_detail *cd, struct ent *item)
{ {
...@@ -381,7 +377,8 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen) ...@@ -381,7 +377,8 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
memset(&ent, 0, sizeof(ent)); memset(&ent, 0, sizeof(ent));
/* Authentication name */ /* 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; goto out;
memcpy(ent.authname, buf1, sizeof(ent.authname)); memcpy(ent.authname, buf1, sizeof(ent.authname));
...@@ -421,7 +418,6 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen) ...@@ -421,7 +418,6 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
error = 0; error = 0;
out: out:
kfree(buf1); kfree(buf1);
return (error); return (error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment