krb5 commit: Fix clntraw_create initialization

Greg Hudson ghudson at MIT.EDU
Thu Dec 20 14:29:30 EST 2012


https://github.com/krb5/krb5/commit/8b43dd0cec3645d64e4eb9f6d0fcfc2a31d1955d
commit 8b43dd0cec3645d64e4eb9f6d0fcfc2a31d1955d
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Dec 20 14:00:37 2012 -0500

    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 <nickolai at csail.mit.edu>.
    
    ticket: 7511

 src/lib/rpc/clnt_raw.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/lib/rpc/clnt_raw.c b/src/lib/rpc/clnt_raw.c
index df86094..1d7fc62 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
 	 */


More information about the cvs-krb5 mailing list