Skip to contentSkip to conversation

Avoid buffer overruns by allocating buffer in svcauth_gss_validate()

PATCH Superseded Steve Dickson 1 participant 1 message May 28, 2014

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Avoid buffer overruns by allocating buffer in svcauth_gss_validate()

---
 src/svc_auth_gss.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
src/svc_auth_gss.c +7 -7
index 601a691..0766959 100644
@@ -286,21 +286,21 @@ svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg)
 	struct opaque_auth	*oa;
 	gss_buffer_desc		 rpcbuf, checksum;
 	OM_uint32		 maj_stat, min_stat, qop_state;
-	u_char			 rpchdr[128];
+	u_char			 *rpchdr;
 	int32_t			*buf;
+	u_int			bufsz;
 
 	gss_log_debug("in svcauth_gss_validate()");
 
-	memset(rpchdr, 0, sizeof(rpchdr));
-
 	/* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */
 	oa = &msg->rm_call.cb_cred;
-	if (oa->oa_length > MAX_AUTH_BYTES)
+
+	bufsz = ((8 * BYTES_PER_XDR_UNIT) + RNDUP(oa->oa_length));
+	if (bufsz > MAX_AUTH_BYTES)
 		return (FALSE);
 	
-	/* 8 XDR units from the IXDR macro calls. */
-	if (sizeof(rpchdr) < (8 * BYTES_PER_XDR_UNIT +
-			RNDUP(oa->oa_length)))
+	rpchdr = (u_char *)calloc(bufsz, 1);
+	if (rpchdr == NULL)
 		return (FALSE);
 
 	buf = (int32_t *)rpchdr;
Signature · 1 line
1.7.1