Blame SOURCES/rpcbind-0.2.0-freeing-static-memory.patch

bec77d
diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
bec77d
index 0c34632..0f104a6 100644
bec77d
--- a/src/rpcb_svc_com.c
bec77d
+++ b/src/rpcb_svc_com.c
bec77d
@@ -616,9 +616,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 	struct netconfig *nconf;
bec77d
 	struct netbuf *caller;
bec77d
 	struct r_rmtcall_args a;
bec77d
-	char *buf_alloc = NULL, *outbufp;
bec77d
-	char *outbuf_alloc = NULL;
bec77d
-	char buf[RPC_BUF_MAX], outbuf[RPC_BUF_MAX];
bec77d
+	char  outbuf[RPC_BUF_MAX];
bec77d
 	struct netbuf *na = (struct netbuf *) NULL;
bec77d
 	struct rpc_msg call_msg;
bec77d
 	int outlen;
bec77d
@@ -639,36 +637,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 	}
bec77d
 	if (si.si_socktype != SOCK_DGRAM)
bec77d
 		return;	/* Only datagram type accepted */
bec77d
-	sendsz = __rpc_get_t_size(si.si_af, si.si_proto, UDPMSGSIZE);
bec77d
-	if (sendsz == 0) {	/* data transfer not supported */
bec77d
-		if (reply_type == RPCBPROC_INDIRECT)
bec77d
-			svcerr_systemerr(transp);
bec77d
-		return;
bec77d
-	}
bec77d
-	/*
bec77d
-	 * Should be multiple of 4 for XDR.
bec77d
-	 */
bec77d
-	sendsz = ((sendsz + 3) / 4) * 4;
bec77d
-	if (sendsz > RPC_BUF_MAX) {
bec77d
-#ifdef	notyet
bec77d
-		buf_alloc = alloca(sendsz);		/* not in IDR2? */
bec77d
-#else
bec77d
-		buf_alloc = malloc(sendsz);
bec77d
-#endif	/* notyet */
bec77d
-		if (buf_alloc == NULL) {
bec77d
-			if (debugging)
bec77d
-				xlog(LOG_DEBUG,
bec77d
-					"rpcbproc_callit_com:  No Memory!\n");
bec77d
-			if (reply_type == RPCBPROC_INDIRECT)
bec77d
-				svcerr_systemerr(transp);
bec77d
-			return;
bec77d
-		}
bec77d
-		a.rmt_args.args = buf_alloc;
bec77d
-	} else {
bec77d
-		a.rmt_args.args = buf;
bec77d
-	}
bec77d
+	sendsz = UDPMSGSIZE;
bec77d
 
bec77d
 	call_msg.rm_xid = 0;	/* For error checking purposes */
bec77d
+	memset(&a, 0, sizeof(a)); /* Zero out the input buffer */
bec77d
 	if (!svc_getargs(transp, (xdrproc_t) xdr_rmtcall_args, (char *) &a)) {
bec77d
 		if (reply_type == RPCBPROC_INDIRECT)
bec77d
 			svcerr_decode(transp);
bec77d
@@ -704,11 +676,11 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 
bec77d
 	rpcbs_rmtcall(versnum - 2, reply_type, a.rmt_prog, a.rmt_vers,
bec77d
 			a.rmt_proc, transp->xp_netid, rbl);
bec77d
-
bec77d
 	if (rbl == (rpcblist_ptr)NULL) {
bec77d
 #ifdef RPCBIND_DEBUG
bec77d
 		if (debugging)
bec77d
-			xlog(LOG_DEBUG, "not found\n");
bec77d
+			xlog(LOG_DEBUG, "prog %lu vers %lu: not found\n", 
bec77d
+				a.rmt_prog, a.rmt_vers);
bec77d
 #endif
bec77d
 		if (reply_type == RPCBPROC_INDIRECT)
bec77d
 			svcerr_noprog(transp);
bec77d
@@ -822,24 +794,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
bec77d
 	call_msg.rm_call.cb_prog = a.rmt_prog;
bec77d
 	call_msg.rm_call.cb_vers = a.rmt_vers;
bec77d
-	if (sendsz > RPC_BUF_MAX) {
bec77d
-#ifdef	notyet
bec77d
-		outbuf_alloc = alloca(sendsz);	/* not in IDR2? */
bec77d
-#else
bec77d
-		outbuf_alloc = malloc(sendsz);
bec77d
-#endif	/* notyet */
bec77d
-		if (outbuf_alloc == NULL) {
bec77d
-			if (reply_type == RPCBPROC_INDIRECT)
bec77d
-				svcerr_systemerr(transp);
bec77d
-			if (debugging)
bec77d
-				xlog(LOG_DEBUG,
bec77d
-				"rpcbproc_callit_com:  No memory!\n");
bec77d
-			goto error;
bec77d
-		}
bec77d
-		xdrmem_create(&outxdr, outbuf_alloc, sendsz, XDR_ENCODE);
bec77d
-	} else {
bec77d
-		xdrmem_create(&outxdr, outbuf, sendsz, XDR_ENCODE);
bec77d
-	}
bec77d
+
bec77d
+	memset(outbuf, '\0', sendsz); /* Zero out the output buffer */
bec77d
+	xdrmem_create(&outxdr, outbuf, sendsz, XDR_ENCODE);
bec77d
+
bec77d
 	if (!xdr_callhdr(&outxdr, &call_msg)) {
bec77d
 		if (reply_type == RPCBPROC_INDIRECT)
bec77d
 			svcerr_systemerr(transp);
bec77d
@@ -904,10 +862,6 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 		goto error;
bec77d
 	}
bec77d
 	outlen = (int) XDR_GETPOS(&outxdr);
bec77d
-	if (outbuf_alloc)
bec77d
-		outbufp = outbuf_alloc;
bec77d
-	else
bec77d
-		outbufp = outbuf;
bec77d
 
bec77d
 	na = uaddr2taddr(nconf, local_uaddr);
bec77d
 	if (!na) {
bec77d
@@ -916,7 +870,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
bec77d
 		goto error;
bec77d
 	}
bec77d
 
bec77d
-	if (sendto(fd, outbufp, outlen, 0, (struct sockaddr *)na->buf, na->len)
bec77d
+	if (sendto(fd, outbuf, outlen, 0, (struct sockaddr *)na->buf, na->len)
bec77d
 	    != outlen) {
bec77d
 		if (debugging)
bec77d
 			xlog(LOG_DEBUG,
bec77d
@@ -941,10 +895,6 @@ out:
bec77d
 	}
bec77d
 	if (local_uaddr)
bec77d
 		free(local_uaddr);
bec77d
-	if (buf_alloc)
bec77d
-		free(buf_alloc);
bec77d
-	if (outbuf_alloc)
bec77d
-		free(outbuf_alloc);
bec77d
 	if (na) {
bec77d
 		free(na->buf);
bec77d
 		free(na);