From fc371f7f6dff40974847db9da6586b709044fe93 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 29 Apr 1997 08:52:31 +0000 Subject: [PATCH] something is wrong with this level of randomness; let 2.1 go out with this "problem" --- lib/libc/rpc/clnt_tcp.c | 4 ++-- lib/libc/rpc/clnt_udp.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index 387521d4063..ae13ad0ae00 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: clnt_tcp.c,v 1.13 1997/04/27 22:23:31 deraadt Exp $"; +static char *rcsid = "$OpenBSD: clnt_tcp.c,v 1.14 1997/04/29 08:52:31 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -251,7 +251,7 @@ clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) call_again: xdrs->x_op = XDR_ENCODE; ct->ct_error.re_status = RPC_SUCCESS; - x_id = *msg_x_id = arc4random(); + x_id = ntohl(--(*msg_x_id)); if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || (! XDR_PUTLONG(xdrs, (long *)&proc)) || (! AUTH_MARSHALL(h->cl_auth, xdrs)) || diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index 2cce6a79828..866315fb691 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.11 1997/04/27 22:23:33 deraadt Exp $"; +static char *rcsid = "$OpenBSD: clnt_udp.c,v 1.12 1997/04/29 08:52:33 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -224,7 +224,6 @@ clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) struct rpc_msg reply_msg; XDR reply_xdrs; struct timeval time_waited, start, after, tmp1, tmp2; - u_int32_t *msg_x_id = (u_int32_t *)(cu->cu_outbuf); /* yuk */ bool_t ok; int nrefreshes = 2; /* number of times to refresh cred */ struct timeval timeout; @@ -250,7 +249,10 @@ call_again: xdrs = &(cu->cu_outxdrs); xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, cu->cu_xdrpos); - *msg_x_id = arc4random(); + /* + * the transaction is the first thing in the out buffer + */ + (*(u_short *)(cu->cu_outbuf))++; if (!XDR_PUTLONG(xdrs, (long *)&proc) || !AUTH_MARSHALL(cl->cl_auth, xdrs) || !(*xargs)(xdrs, argsp)) { @@ -335,7 +337,7 @@ send_again: if (inlen < sizeof(u_int32_t)) continue; /* see if reply transaction id matches sent id */ - if (*((u_int32_t *)(cu->cu_inbuf)) != *msg_x_id) + if (*((u_int32_t *)(cu->cu_inbuf)) != *((u_int32_t *)(cu->cu_outbuf))) continue; /* we now assume we have the proper reply */ break; -- 2.20.1