]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFSD: Replace READ* macros in nfsd4_decode_commit()
authorChuck Lever <chuck.lever@oracle.com>
Tue, 3 Nov 2020 18:19:51 +0000 (13:19 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Nov 2020 19:46:36 +0000 (14:46 -0500)
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4xdr.c
include/linux/sunrpc/xdr.h

index 1e5188b2f9439c7d61fd204131e88f516a7a4ec4..ff1e3621d9779f3c775d46b354fe6cc9b9712e90 100644 (file)
@@ -581,13 +581,11 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
 static __be32
 nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit)
 {
-       DECODE_HEAD;
-
-       READ_BUF(12);
-       p = xdr_decode_hyper(p, &commit->co_offset);
-       commit->co_count = be32_to_cpup(p++);
-
-       DECODE_TAIL;
+       if (xdr_stream_decode_u64(argp->xdr, &commit->co_offset) < 0)
+               return nfserr_bad_xdr;
+       if (xdr_stream_decode_u32(argp->xdr, &commit->co_count) < 0)
+               return nfserr_bad_xdr;
+       return nfs_ok;
 }
 
 static __be32
index cc64cd0891f18e7a18f8e318a83556a29a2abe4d..cc669d95c484edd407e30ee26aab0e35eac8a34a 100644 (file)
@@ -571,6 +571,27 @@ xdr_stream_decode_u32(struct xdr_stream *xdr, __u32 *ptr)
        return 0;
 }
 
+/**
+ * xdr_stream_decode_u64 - Decode a 64-bit integer
+ * @xdr: pointer to xdr_stream
+ * @ptr: location to store 64-bit integer
+ *
+ * Return values:
+ *   %0 on success
+ *   %-EBADMSG on XDR buffer overflow
+ */
+static inline ssize_t
+xdr_stream_decode_u64(struct xdr_stream *xdr, __u64 *ptr)
+{
+       const size_t count = sizeof(*ptr);
+       __be32 *p = xdr_inline_decode(xdr, count);
+
+       if (unlikely(!p))
+               return -EBADMSG;
+       xdr_decode_hyper(p, ptr);
+       return 0;
+}
+
 /**
  * xdr_stream_decode_opaque_fixed - Decode fixed length opaque xdr data
  * @xdr: pointer to xdr_stream