summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormig <mig>2013-01-04 05:26:40 (GMT)
committermig <mig>2013-01-04 05:26:40 (GMT)
commit047d22960723097544bbeda5eefb066d71b7e38f (patch)
treec6a56776e78090be844eacac0d757f5cb932b267
parentf889a9294bd1a1c5df632d4ff4919abf81d72127 (diff)
downloadtcl-047d22960723097544bbeda5eefb066d71b7e38f.zip
tcl-047d22960723097544bbeda5eefb066d71b7e38f.tar.gz
tcl-047d22960723097544bbeda5eefb066d71b7e38f.tar.bz2
Insure that PURIFY builds cannot exploit the Tcl stack to hide mem defects.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclExecute.c14
-rw-r--r--generic/tclInt.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 93cf3a2..3dd2b9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-04 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclInt.h: Insure that PURIFY builds cannot exploit the
+ * generic/tclExecute.c: Tcl stack to hide mem defects.
+
2013-01-03 Donal K. Fellows <dkf@users.sf.net>
* doc/fconfigure.n, doc/CrtChannel.3: Updated to reflect the fact that
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 9fcc8a5..3635bab 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1048,6 +1048,7 @@ GrowEvaluationStack(
return MEMSTART(markerPtr);
}
} else {
+#ifndef PURIFY
Tcl_Obj **tmpMarkerPtr = esPtr->tosPtr + 1;
int offset = OFFSET(tmpMarkerPtr);
@@ -1064,6 +1065,7 @@ GrowEvaluationStack(
*esPtr->markerPtr = (Tcl_Obj *) markerPtr;
return memStart;
}
+#endif
}
/*
@@ -1075,8 +1077,9 @@ GrowEvaluationStack(
if (move) {
moveWords = esPtr->tosPtr - MEMSTART(markerPtr) + 1;
}
- needed = growth + moveWords + WALLOCALIGN;
+ needed = growth + moveWords + WALLOCALIGN - 1;
+
/*
* Check if there is enough room in the next stack (if there is one, it
* should be both empty and the last one!)
@@ -1106,10 +1109,15 @@ GrowEvaluationStack(
* including the elements to be copied over and the new marker.
*/
+#ifndef PURIFY
newElems = 2*currElems;
while (needed > newElems) {
newElems *= 2;
}
+#else
+ newElems = needed;
+#endif
+
newBytes = sizeof(ExecStack) + (newElems-1) * sizeof(Tcl_Obj *);
oldPtr = esPtr;
@@ -1258,6 +1266,10 @@ TclStackFree(
}
if (esPtr->prevPtr) {
eePtr->execStackPtr = esPtr->prevPtr;
+#ifdef PURIFY
+ eePtr->execStackPtr->nextPtr = NULL;
+ DeleteExecStack(esPtr);
+#endif
} else {
eePtr->execStackPtr = esPtr;
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 52f1a32..dd3c1cd 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4014,6 +4014,7 @@ typedef const char *TclDTraceStr;
ckfree((char *) (objPtr))
#undef USE_THREAD_ALLOC
+#undef USE_TCLALLOC
#elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
/*