summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/clnt_raw.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1997-11-05 10:00:20 +0000
committerderaadt <deraadt@openbsd.org>1997-11-05 10:00:20 +0000
commitb1ed0aaa09bbe0d87fd75a8b21180649f634263e (patch)
treefc8b2671990c5888887cdb48b8640a6d19db9a0b /lib/libc/rpc/clnt_raw.c
parent.cxx support from Mathieu.Herrb@mipnet.fr (diff)
downloadwireguard-openbsd-b1ed0aaa09bbe0d87fd75a8b21180649f634263e.tar.xz
wireguard-openbsd-b1ed0aaa09bbe0d87fd75a8b21180649f634263e.zip
if xdr_replymsg() fails, it can leave memory still allocated. thus we
need to go XDR_FREE it; wpaul@freebsd. clnt_raw.c also appears to have the same problem, and there is precedent for the solution in various other rpc code.
Diffstat (limited to 'lib/libc/rpc/clnt_raw.c')
-rw-r--r--lib/libc/rpc/clnt_raw.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c
index e9cf2455f89..9885f0878ec 100644
--- a/lib/libc/rpc/clnt_raw.c
+++ b/lib/libc/rpc/clnt_raw.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: clnt_raw.c,v 1.5 1996/12/14 06:49:41 tholo Exp $";
+static char *rcsid = "$OpenBSD: clnt_raw.c,v 1.6 1997/11/05 10:00:20 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -170,8 +170,15 @@ call_again:
msg.acpted_rply.ar_verf = _null_auth;
msg.acpted_rply.ar_results.where = resultsp;
msg.acpted_rply.ar_results.proc = xresults;
- if (! xdr_replymsg(xdrs, &msg))
+ if (! xdr_replymsg(xdrs, &msg)) {
+ /* xdr_replymsg() may have left some things allocated */
+ int op = reply_xdrs.x_op;
+ reply_xdrs.x_op = XDR_FREE;
+ xdr_replymsg(&reply_xdrs, &reply_msg);
+ reply_xdrs.x_op = op;
+ cu->cu_error.re_status = RPC_CANTDECODERES;
return (RPC_CANTDECODERES);
+ }
_seterr_reply(&msg, &error);
status = error.re_status;