From: Greg Hudson Date: Thu, 20 Dec 2012 19:00:37 +0000 (-0500) Subject: Fix clntraw_create initialization X-Git-Tag: krb5-1.12-alpha1~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b43dd0cec3645d64e4eb9f6d0fcfc2a31d1955d;p=thirdparty%2Fkrb5.git Fix clntraw_create initialization clntraw_create has been broken since inception; on the first call, it would compute invalid values of xdrs and client and dereference them. Fix that. (This is pretty strong evidence that no one has ever used it.) Reported by Nickolai Zeldovich . ticket: 7511 --- diff --git a/src/lib/rpc/clnt_raw.c b/src/lib/rpc/clnt_raw.c index df86094cc7..1d7fc62604 100644 --- a/src/lib/rpc/clnt_raw.c +++ b/src/lib/rpc/clnt_raw.c @@ -90,17 +90,19 @@ clntraw_create( rpcprog_t prog, rpcvers_t vers) { - register struct clntraw_private *clp = clntraw_private; + struct clntraw_private *clp; struct rpc_msg call_msg; - XDR *xdrs = &clp->xdr_stream; - CLIENT *client = &clp->client_object; + XDR *xdrs; + CLIENT *client; - if (clp == 0) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); - if (clp == 0) - return (0); - clntraw_private = clp; + if (clntraw_private == NULL) { + clntraw_private = calloc(1, sizeof(*clp)); + if (clntraw_private == NULL) + return (NULL); } + clp = clntraw_private; + xdrs = &clp->xdr_stream; + client = &clp->client_object; /* * pre-serialize the staic part of the call msg and stash it away */