diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-10-10 15:07:40 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-10-11 12:15:01 -0400 |
commit | a084daf512bb66fa3c8e21c7027daea521179cd0 (patch) | |
tree | ae3432178013d3b474adac890dad3fb7262f9746 /fs/nfsd/nfs4xdr.c | |
parent | 04f9e664b21c4440daf4d08f31db9b18517e4b8d (diff) |
nfsd4: move name-length checks to xdr
Again, these checks are better in the xdr code.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 94da8bb36c85..2cab33cc3238 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -697,6 +697,23 @@ xdr_error: | |||
697 | return nfserr_bad_xdr; | 697 | return nfserr_bad_xdr; |
698 | } | 698 | } |
699 | 699 | ||
700 | static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_netobj *o) | ||
701 | { | ||
702 | __be32 *p; | ||
703 | |||
704 | READ_BUF(4); | ||
705 | READ32(o->len); | ||
706 | |||
707 | if (o->len == 0 || o->len > NFS4_OPAQUE_LIMIT) | ||
708 | return nfserr_bad_xdr; | ||
709 | |||
710 | READ_BUF(o->len); | ||
711 | SAVEMEM(o->data, o->len); | ||
712 | return nfs_ok; | ||
713 | xdr_error: | ||
714 | return nfserr_bad_xdr; | ||
715 | } | ||
716 | |||
700 | static __be32 | 717 | static __be32 |
701 | nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) | 718 | nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) |
702 | { | 719 | { |
@@ -715,13 +732,12 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) | |||
715 | status = nfsd4_decode_share_deny(argp, &open->op_share_deny); | 732 | status = nfsd4_decode_share_deny(argp, &open->op_share_deny); |
716 | if (status) | 733 | if (status) |
717 | goto xdr_error; | 734 | goto xdr_error; |
718 | READ_BUF(sizeof(clientid_t) + 4); | 735 | READ_BUF(sizeof(clientid_t)); |
719 | COPYMEM(&open->op_clientid, sizeof(clientid_t)); | 736 | COPYMEM(&open->op_clientid, sizeof(clientid_t)); |
720 | READ32(open->op_owner.len); | 737 | status = nfsd4_decode_opaque(argp, &open->op_owner); |
721 | 738 | if (status) | |
722 | /* owner, open_flag */ | 739 | goto xdr_error; |
723 | READ_BUF(open->op_owner.len + 4); | 740 | READ_BUF(4); |
724 | SAVEMEM(open->op_owner.data, open->op_owner.len); | ||
725 | READ32(open->op_create); | 741 | READ32(open->op_create); |
726 | switch (open->op_create) { | 742 | switch (open->op_create) { |
727 | case NFS4_OPEN_NOCREATE: | 743 | case NFS4_OPEN_NOCREATE: |
@@ -964,12 +980,13 @@ nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclient | |||
964 | { | 980 | { |
965 | DECODE_HEAD; | 981 | DECODE_HEAD; |
966 | 982 | ||
967 | READ_BUF(12); | 983 | READ_BUF(8); |
968 | COPYMEM(setclientid->se_verf.data, 8); | 984 | COPYMEM(setclientid->se_verf.data, 8); |
969 | READ32(setclientid->se_namelen); | ||
970 | 985 | ||
971 | READ_BUF(setclientid->se_namelen + 8); | 986 | status = nfsd4_decode_opaque(argp, &setclientid->se_name); |
972 | SAVEMEM(setclientid->se_name, setclientid->se_namelen); | 987 | if (status) |
988 | return nfserr_bad_xdr; | ||
989 | READ_BUF(8); | ||
973 | READ32(setclientid->se_callback_prog); | 990 | READ32(setclientid->se_callback_prog); |
974 | READ32(setclientid->se_callback_netid_len); | 991 | READ32(setclientid->se_callback_netid_len); |
975 | 992 | ||
@@ -1112,11 +1129,9 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, | |||
1112 | READ_BUF(NFS4_VERIFIER_SIZE); | 1129 | READ_BUF(NFS4_VERIFIER_SIZE); |
1113 | COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); | 1130 | COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); |
1114 | 1131 | ||
1115 | READ_BUF(4); | 1132 | status = nfsd4_decode_opaque(argp, &exid->clname); |
1116 | READ32(exid->clname.len); | 1133 | if (status) |
1117 | 1134 | return nfserr_bad_xdr; | |
1118 | READ_BUF(exid->clname.len); | ||
1119 | SAVEMEM(exid->clname.data, exid->clname.len); | ||
1120 | 1135 | ||
1121 | READ_BUF(4); | 1136 | READ_BUF(4); |
1122 | READ32(exid->flags); | 1137 | READ32(exid->flags); |