Module Name:    src
Committed By:   tteras
Date:           Mon Apr 20 13:35:36 UTC 2009

Modified Files:
        src/crypto/dist/ipsec-tools/src/racoon [ipsec-tools-0_7-branch]:
            isakmp_inf.c isakmp_xauth.c plog.c

Log Message:
Orignally from Bin Li: Fix possible memory corruption in binsanitize().


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.15 -r1.14.4.16 \
    src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 \
    src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c
cvs rdiff -u -r1.4.6.1 -r1.4.6.2 \
    src/crypto/dist/ipsec-tools/src/racoon/plog.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c:1.14.4.15 src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c:1.14.4.16
--- src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c:1.14.4.15	Wed Sep 17 12:49:50 2008
+++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c	Mon Apr 20 13:35:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: isakmp_inf.c,v 1.14.4.15 2008/09/17 12:49:50 vanhu Exp $	*/
+/*	$NetBSD: isakmp_inf.c,v 1.14.4.16 2009/04/20 13:35:36 tteras Exp $	*/
 
 /* Id: isakmp_inf.c,v 1.44 2006/05/06 20:45:52 manubsd Exp */
 
@@ -339,8 +339,7 @@
 {
 	u_int type;
 	vchar_t *pbuf;
-	vchar_t *ndata;
-	char *nraw;
+	char *nraw, *ndata;
 	size_t l;
 	char *spi;
 
@@ -430,12 +429,12 @@
 		if (l > 0) {
 			nraw = (char*)notify;	
 			nraw += sizeof(*notify) + notify->spi_size;
-			if ((ndata = vmalloc(l)) != NULL) {
-				memcpy(ndata->v, nraw, ndata->l);
+			ndata = binsanitize(nraw, l);
+			if (ndata != NULL) {
 				plog(LLV_ERROR, LOCATION, iph1->remote,
 				    "Message: '%s'.\n", 
-				    binsanitize(ndata->v, ndata->l));
-				vfree(ndata);
+				    ndata);
+				racoon_free(ndata);
 			} else {
 				plog(LLV_ERROR, LOCATION, iph1->remote,
 				    "Cannot allocate memory\n");

Index: src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.11.6.1 src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.11.6.2
--- src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.11.6.1	Tue Aug  7 04:49:24 2007
+++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c	Mon Apr 20 13:35:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: isakmp_xauth.c,v 1.11.6.1 2007/08/07 04:49:24 manu Exp $	*/
+/*	$NetBSD: isakmp_xauth.c,v 1.11.6.2 2009/04/20 13:35:36 tteras Exp $	*/
 
 /* Id: isakmp_xauth.c,v 1.38 2006/08/22 18:17:17 manubsd Exp */
 
@@ -1372,8 +1372,7 @@
 	int ashort = 0;
 	int value = 0;
 	vchar_t *buffer = NULL;
-	char* mraw = NULL;
-	vchar_t *mdata = NULL;
+	char *mraw = NULL, *mdata;
 	char *data;
 	vchar_t *usr = NULL;
 	vchar_t *pwd = NULL;
@@ -1460,16 +1459,16 @@
 			dlen = ntohs(attr->lorv);
 			if (dlen > 0) {
 				mraw = (char*)(attr + 1);
-				if ((mdata = vmalloc(dlen)) == NULL) {
+				mdata = binsanitize(mraw, dlen);
+				if (mdata == NULL) {
 					plog(LLV_ERROR, LOCATION, iph1->remote,
 					    "Cannot allocate memory\n");
 					return NULL;
 				}
-				memcpy(mdata->v, mraw, mdata->l);
 				plog(LLV_NOTIFY,LOCATION, iph1->remote,
 					"XAUTH Message: '%s'.\n",
-					binsanitize(mdata->v, mdata->l));
-				vfree(mdata);
+					mdata);
+				racoon_free(mdata);
 			}
 		}
 		return NULL;
@@ -1529,8 +1528,7 @@
 	char *data;
 	struct xauth_state *xst;
 	size_t dlen = 0;
-	char* mraw = NULL;
-	vchar_t *mdata = NULL;
+	char* mraw = NULL, *mdata;
 
 	if ((iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_XAUTH) == 0) {
 		plog(LLV_ERROR, LOCATION, NULL, 
@@ -1587,16 +1585,16 @@
 			dlen = ntohs(attr->lorv);
 			if (dlen > 0) {
 				mraw = (char*)(attr + 1);
-				if ((mdata = vmalloc(dlen)) == NULL) {
+				mdata = binsanitize(mraw, dlen);
+				if (mdata == NULL) {
 					plog(LLV_ERROR, LOCATION, iph1->remote,
 					    "Cannot allocate memory\n");
 					return NULL;
 				}
-				memcpy(mdata->v, mraw, mdata->l);
 				plog(LLV_NOTIFY,LOCATION, iph1->remote,
 					"XAUTH Message: '%s'.\n",
-					binsanitize(mdata->v, mdata->l));
-				vfree(mdata);
+					mdata);
+				racoon_free(mdata);
 			}
 		}
 

Index: src/crypto/dist/ipsec-tools/src/racoon/plog.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/plog.c:1.4.6.1 src/crypto/dist/ipsec-tools/src/racoon/plog.c:1.4.6.2
--- src/crypto/dist/ipsec-tools/src/racoon/plog.c:1.4.6.1	Tue Nov  6 16:41:27 2007
+++ src/crypto/dist/ipsec-tools/src/racoon/plog.c	Mon Apr 20 13:35:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: plog.c,v 1.4.6.1 2007/11/06 16:41:27 vanhu Exp $	*/
+/*	$NetBSD: plog.c,v 1.4.6.2 2009/04/20 13:35:36 tteras Exp $	*/
 
 /* Id: plog.c,v 1.11 2006/06/20 09:57:31 vanhu Exp */
 
@@ -251,15 +251,18 @@
 {
 	int p,q;
 	char* d;
+
+	d = racoon_malloc(n + 1);
 	for (p = 0, q = 0; p < n; p++) {
-                 if (isgraph((int)binstr[p])) {
-			binstr[q++] = binstr[p];
+		if (isgraph((int)binstr[p])) {
+			d[q++] = binstr[p];
 		} else {
-			if (q && binstr[q - 1] != ' ')
-				 binstr[q++] = ' ';
+			if (q && d[q - 1] != ' ')
+				d[q++] = ' ';
 		}
 	}
-	binstr[q++] = '\0';
-	return binstr;
+	d[q++] = '\0';
+
+	return d;
 }
 	

Reply via email to