]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix clntraw_create initialization
authorGreg Hudson <ghudson@mit.edu>
Thu, 20 Dec 2012 19:00:37 +0000 (14:00 -0500)
committerGreg Hudson <ghudson@mit.edu>
Thu, 20 Dec 2012 19:27:38 +0000 (14:27 -0500)
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 <nickolai@csail.mit.edu>.

ticket: 7511

src/lib/rpc/clnt_raw.c

index df86094cc75affc09c8ce4d5f9d9a9074fc141d0..1d7fc626048b2cfbd4f33c4c72a7cafb9e9aab76 100644 (file)
@@ -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
         */