Skip to content

Commit

Permalink
SUNRPC: Introduce xdr_stream-based decoders for RPCB_UNSET
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Aug 9, 2009
1 parent 0d36c4f commit 7ed0ff9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,28 @@ static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p,
return 0;
}

static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p,
unsigned int *boolp)
{
struct rpc_task *task = req->rq_task;
struct xdr_stream xdr;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);

p = xdr_inline_decode(&xdr, sizeof(__be32));
if (unlikely(p == NULL))
return -EIO;

*boolp = 0;
if (*p)
*boolp = 1;

dprintk("RPC: %5u RPCB_%s call %s\n",
task->tk_pid, task->tk_msg.rpc_proc->p_name,
(*boolp ? "succeeded" : "failed"));
return 0;
}

static int encode_rpcb_string(struct xdr_stream *xdr, const char *string,
const u32 maxstrlen)
{
Expand Down

0 comments on commit 7ed0ff9

Please sign in to comment.