diff options
author | 1997-11-05 10:00:20 +0000 | |
---|---|---|
committer | 1997-11-05 10:00:20 +0000 | |
commit | b1ed0aaa09bbe0d87fd75a8b21180649f634263e (patch) | |
tree | fc8b2671990c5888887cdb48b8640a6d19db9a0b /lib/libc | |
parent | .cxx support from Mathieu.Herrb@mipnet.fr (diff) | |
download | wireguard-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')
-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); |