Blame SOURCES/libtirpc-0.2.4-svc-buffer-overflow.patch

8dd2ab
commit cf2e0082ce88fc2c75479c26a4b9f69f1b028c80
8dd2ab
Author: Steve Dickson <steved@redhat.com>
8dd2ab
Date:   Thu May 29 09:40:59 2014 -0400
8dd2ab
8dd2ab
    Avoid buffer overruns by allocating buffer in svcauth_gss_validate()
8dd2ab
    
8dd2ab
    Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
8dd2ab
    Signed-off-by: Steve Dickson <steved@redhat.com>
8dd2ab
8dd2ab
diff --git a/src/svc_auth_gss.c b/src/svc_auth_gss.c
8dd2ab
index 601a691..26c1065 100644
8dd2ab
--- a/src/svc_auth_gss.c
8dd2ab
+++ b/src/svc_auth_gss.c
8dd2ab
@@ -286,21 +286,19 @@ svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg)
8dd2ab
 	struct opaque_auth	*oa;
8dd2ab
 	gss_buffer_desc		 rpcbuf, checksum;
8dd2ab
 	OM_uint32		 maj_stat, min_stat, qop_state;
8dd2ab
-	u_char			 rpchdr[128];
8dd2ab
+	u_char			 *rpchdr;
8dd2ab
 	int32_t			*buf;
8dd2ab
 
8dd2ab
 	gss_log_debug("in svcauth_gss_validate()");
8dd2ab
 
8dd2ab
-	memset(rpchdr, 0, sizeof(rpchdr));
8dd2ab
-
8dd2ab
 	/* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */
8dd2ab
 	oa = &msg->rm_call.cb_cred;
8dd2ab
 	if (oa->oa_length > MAX_AUTH_BYTES)
8dd2ab
 		return (FALSE);
8dd2ab
-	
8dd2ab
-	/* 8 XDR units from the IXDR macro calls. */
8dd2ab
-	if (sizeof(rpchdr) < (8 * BYTES_PER_XDR_UNIT +
8dd2ab
-			RNDUP(oa->oa_length)))
8dd2ab
+
8dd2ab
+	rpchdr = (u_char *)calloc(((8 * BYTES_PER_XDR_UNIT) + 
8dd2ab
+			RNDUP(oa->oa_length)), 1);
8dd2ab
+	if (rpchdr == NULL)
8dd2ab
 		return (FALSE);
8dd2ab
 
8dd2ab
 	buf = (int32_t *)rpchdr;
8dd2ab
@@ -325,6 +323,8 @@ svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg)
8dd2ab
 	maj_stat = gss_verify_mic(&min_stat, gd->ctx, &rpcbuf, &checksum,
8dd2ab
 				  &qop_state);
8dd2ab
 
8dd2ab
+	free(rpchdr);
8dd2ab
+
8dd2ab
 	if (maj_stat != GSS_S_COMPLETE) {
8dd2ab
 		gss_log_status("gss_verify_mic", maj_stat, min_stat);
8dd2ab
 		return (FALSE);