summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-06-01 10:00:21 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-06-01 10:00:21 (GMT)
commitb9d9c5d8cf8952ed18c89c0b8197438571df9db2 (patch)
tree7da86fe3181444dc5dfacc0e881ae9f1c9ff9d1e /generic
parenta1fad16dd4cc19a02e96f5a89ff1becdf1ff3a21 (diff)
downloadtcl-b9d9c5d8cf8952ed18c89c0b8197438571df9db2.zip
tcl-b9d9c5d8cf8952ed18c89c0b8197438571df9db2.tar.gz
tcl-b9d9c5d8cf8952ed18c89c0b8197438571df9db2.tar.bz2
* generic/tclIO.c (Tcl_SetChannelOption): Invalid settings
for -buffersize weren't being reported as errors and were blindly ignored. Now reports conversion errors to an int and checks ranges for validity. atoi() swapped for Tcl_GetInt().
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 1a40828..db6382b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.74 2004/05/19 19:41:09 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.75 2004/06/01 10:00:21 davygrvy Exp $
*/
#include "tclInt.h"
@@ -6447,8 +6447,19 @@ Tcl_SetChannelOption(interp, chan, optionName, newValue)
return TCL_OK;
} else if ((len > 7) && (optionName[1] == 'b') &&
(strncmp(optionName, "-buffersize", len) == 0)) {
- Tcl_SetChannelBufferSize(chan,
- atoi(newValue)); /* INTL: "C", UTF safe. */
+ int newBufferSize;
+ if (Tcl_GetInt(interp, newValue, &newBufferSize) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (newBufferSize < 10 || newBufferSize > (1024 * 1024)) {
+ if (interp) {
+ Tcl_AppendResult(interp, "bad value for -buffersize: ",
+ "must not be less than 10 or greater than 1Mbyte.",
+ NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_SetChannelBufferSize(chan, newBufferSize);
} else if ((len > 2) && (optionName[1] == 'e') &&
(strncmp(optionName, "-encoding", len) == 0)) {
Tcl_Encoding encoding;