diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-08-09 15:09:42 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-09 15:09:42 -0400 |
commit | 7ed0ff983c8ad30bf4e2b9fdbb299a3e3ec08d08 (patch) | |
tree | e93eedc32104cf0b6f26b5b8a1fbd61b33df5df8 /net | |
parent | 0d36c4f7574d5a33bedd8f0e3c793490d45d83c6 (diff) |
SUNRPC: Introduce xdr_stream-based decoders for RPCB_UNSET
Replace the open-coded decode logic for rpcbind UNSET results with an
xdr_stream-based implementation, similar to what NFSv4 uses, to
protect against buffer overflows.
The new function is unused for the moment.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index e0d7b31e54a7..fe183af5cc72 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -736,6 +736,28 @@ static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p, | |||
736 | return 0; | 736 | return 0; |
737 | } | 737 | } |
738 | 738 | ||
739 | static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p, | ||
740 | unsigned int *boolp) | ||
741 | { | ||
742 | struct rpc_task *task = req->rq_task; | ||
743 | struct xdr_stream xdr; | ||
744 | |||
745 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
746 | |||
747 | p = xdr_inline_decode(&xdr, sizeof(__be32)); | ||
748 | if (unlikely(p == NULL)) | ||
749 | return -EIO; | ||
750 | |||
751 | *boolp = 0; | ||
752 | if (*p) | ||
753 | *boolp = 1; | ||
754 | |||
755 | dprintk("RPC: %5u RPCB_%s call %s\n", | ||
756 | task->tk_pid, task->tk_msg.rpc_proc->p_name, | ||
757 | (*boolp ? "succeeded" : "failed")); | ||
758 | return 0; | ||
759 | } | ||
760 | |||
739 | static int encode_rpcb_string(struct xdr_stream *xdr, const char *string, | 761 | static int encode_rpcb_string(struct xdr_stream *xdr, const char *string, |
740 | const u32 maxstrlen) | 762 | const u32 maxstrlen) |
741 | { | 763 | { |