aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4acl.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2013-08-27 21:32:25 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-05-28 14:52:34 -0400
commitddd1ea56367202f6c99135cd59de7a97af4c4ffd (patch)
tree623a164aed98fb1d4a3d7ecc337acc88a5b27fec /fs/nfsd/nfs4acl.c
parent5f4ab9458755eddc66912a15319363bf311f7fc8 (diff)
nfsd4: use xdr_reserve_space in attribute encoding
This is a cosmetic change for now; no change in behavior. Note we're just depending on xdr_reserve_space to do the bounds checking for us, we're not really depending on its adjustment of iovec or xdr_buf lengths yet, as those are fixed up by as necessary after the fact by read-link operations and by nfs4svc_encode_compoundres. However we do have to update xdr->iov on read-like operations to prevent xdr_reserve_space from messing with the already-fixed-up length of the the head. When the attribute encoding fails partway through we have to undo the length adjustments made so far. We do it manually for now, but later patches will add an xdr_truncate_encode() helper to handle cases like this. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4acl.c')
-rw-r--r--fs/nfsd/nfs4acl.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index 7c7c02554a81..d714156a19fd 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -919,20 +919,19 @@ nfs4_acl_get_whotype(char *p, u32 len)
919 return NFS4_ACL_WHO_NAMED; 919 return NFS4_ACL_WHO_NAMED;
920} 920}
921 921
922__be32 nfs4_acl_write_who(int who, __be32 **p, int *len) 922__be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who)
923{ 923{
924 __be32 *p;
924 int i; 925 int i;
925 int bytes;
926 926
927 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) { 927 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
928 if (s2t_map[i].type != who) 928 if (s2t_map[i].type != who)
929 continue; 929 continue;
930 bytes = 4 + (XDR_QUADLEN(s2t_map[i].stringlen) << 2); 930 p = xdr_reserve_space(xdr, s2t_map[i].stringlen + 4);
931 if (bytes > *len) 931 if (!p)
932 return nfserr_resource; 932 return nfserr_resource;
933 *p = xdr_encode_opaque(*p, s2t_map[i].string, 933 p = xdr_encode_opaque(p, s2t_map[i].string,
934 s2t_map[i].stringlen); 934 s2t_map[i].stringlen);
935 *len -= bytes;
936 return 0; 935 return 0;
937 } 936 }
938 WARN_ON_ONCE(1); 937 WARN_ON_ONCE(1);