1 From 4e201b75928ff7d4894cd30ab0f5f67b9cd95f5c Mon Sep 17 00:00:00 2001
2 From: Steve Dickson <steved@redhat.com>
3 Date: Thu, 18 Jan 2018 17:33:56 +0000
4 Subject: [PATCH] rpcbproc_callit_com: Stop freeing a static pointer
6 commit 7ea36ee introduced a svc_freeargs() call
7 that ended up freeing static pointer.
9 It turns out the allocations for the rmt_args
10 is not necessary . The xdr routines (xdr_bytes) will
11 handle the memory management and the largest
12 possible message size is UDPMSGSIZE (due to UDP only)
13 which is smaller than RPC_BUF_MAX
15 Signed-off-by: Steve Dickson <steved@redhat.com>
16 (cherry picked from commit 7c7590ad536c0e24bef790cb1e65702fc54db566)
17 Signed-off-by: Ed Blake <ed.blake@sondrel.com>
19 src/rpcb_svc_com.c | 39 ++++++---------------------------------
20 1 file changed, 6 insertions(+), 33 deletions(-)
22 diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
23 index 0432b6f..64f1104 100644
24 --- a/src/rpcb_svc_com.c
25 +++ b/src/rpcb_svc_com.c
26 @@ -616,9 +616,9 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
27 struct netconfig *nconf;
28 struct netbuf *caller;
29 struct r_rmtcall_args a;
30 - char *buf_alloc = NULL, *outbufp;
32 char *outbuf_alloc = NULL;
33 - char buf[RPC_BUF_MAX], outbuf[RPC_BUF_MAX];
34 + char outbuf[RPC_BUF_MAX];
35 struct netbuf *na = (struct netbuf *) NULL;
36 struct rpc_msg call_msg;
38 @@ -639,36 +639,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
40 if (si.si_socktype != SOCK_DGRAM)
41 return; /* Only datagram type accepted */
42 - sendsz = __rpc_get_t_size(si.si_af, si.si_proto, UDPMSGSIZE);
43 - if (sendsz == 0) { /* data transfer not supported */
44 - if (reply_type == RPCBPROC_INDIRECT)
45 - svcerr_systemerr(transp);
49 - * Should be multiple of 4 for XDR.
51 - sendsz = ((sendsz + 3) / 4) * 4;
52 - if (sendsz > RPC_BUF_MAX) {
54 - buf_alloc = alloca(sendsz); /* not in IDR2? */
56 - buf_alloc = malloc(sendsz);
58 - if (buf_alloc == NULL) {
61 - "rpcbproc_callit_com: No Memory!\n");
62 - if (reply_type == RPCBPROC_INDIRECT)
63 - svcerr_systemerr(transp);
66 - a.rmt_args.args = buf_alloc;
68 - a.rmt_args.args = buf;
70 + sendsz = UDPMSGSIZE;
72 call_msg.rm_xid = 0; /* For error checking purposes */
73 + memset(&a, 0, sizeof(a)); /* Zero out the input buffer */
74 if (!svc_getargs(transp, (xdrproc_t) xdr_rmtcall_args, (char *) &a)) {
75 if (reply_type == RPCBPROC_INDIRECT)
76 svcerr_decode(transp);
77 @@ -708,7 +682,8 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
78 if (rbl == (rpcblist_ptr)NULL) {
81 - xlog(LOG_DEBUG, "not found\n");
82 + xlog(LOG_DEBUG, "prog %lu vers %lu: not found\n",
83 + a.rmt_prog, a.rmt_vers);
85 if (reply_type == RPCBPROC_INDIRECT)
86 svcerr_noprog(transp);
87 @@ -941,8 +916,6 @@ out: