diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-05 10:00:23 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-05 10:00:23 +0000 |
commit | eedd3e47495b9a5cf600b4fd2613eaf91412f9cb (patch) | |
tree | 0f737699996de7d5db9374e79ceb797fe390f25c /lib | |
parent | 6c99f5ed69766ce2b4f49ab0814d87d5b42fe268 (diff) |
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')
-rw-r--r-- | lib/libc/rpc/clnt_raw.c | 11 | ||||
-rw-r--r-- | lib/libc/rpc/clnt_udp.c | 10 |
2 files changed, 17 insertions, 4 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; diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index f78e5f0976b..9e6b3c447da 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: clnt_udp.c,v 1.13 1997/09/22 05:11:06 millert Exp $"; +static char *rcsid = "$OpenBSD: clnt_udp.c,v 1.14 1997/11/05 10:00:22 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -370,8 +370,14 @@ send_again: goto call_again; } } - } else + } else { + /* 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; + } if (fds != &readfds) free(fds); |