summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-11-17 02:51:31 (GMT)
committerhobbs <hobbs>2004-11-17 02:51:31 (GMT)
commitf064e12fe6a865fc5dcbebfd5caef562b799252e (patch)
treee4d2f2949c9f841063f663c323784b14c4dad966
parent35807a4a773f76ca1b79089bff2fbef95ce5fd78 (diff)
downloadtcl-f064e12fe6a865fc5dcbebfd5caef562b799252e.zip
tcl-f064e12fe6a865fc5dcbebfd5caef562b799252e.tar.gz
tcl-f064e12fe6a865fc5dcbebfd5caef562b799252e.tar.bz2
* unix/tclUnixChan.c (TtySetOptionProc): fixed crash configuring
-ttycontrol on a channel. [Bug 1067708]
-rw-r--r--ChangeLog5
-rw-r--r--unix/tclUnixChan.c20
2 files changed, 15 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 3dbf23a..9a118d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-16 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * unix/tclUnixChan.c (TtySetOptionProc): fixed crash configuring
+ -ttycontrol on a channel. [Bug 1067708]
+
2004-11-16 Don Porter <dgp@users.sourceforge.net>
* generic/tclIOUtil.c (TclFSEpochOk): There were two code paths
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 700b203..5b9fa0a 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.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: tclUnixChan.c,v 1.52 2004/11/10 19:33:52 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.53 2004/11/17 02:51:32 hobbs Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
@@ -980,6 +980,7 @@ TtySetOptionProc(instanceData, interp, optionName, value)
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
+ int i;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
@@ -994,12 +995,12 @@ TtySetOptionProc(instanceData, interp, optionName, value)
}
GETCONTROL(fsPtr->fd, &control);
- while (argc > 1) {
- if (Tcl_GetBoolean(interp, argv[1], &flag) == TCL_ERROR) {
+ for (i = 0; i < argc-1; i += 2) {
+ if (Tcl_GetBoolean(interp, argv[i+1], &flag) == TCL_ERROR) {
ckfree((char *) argv);
return TCL_ERROR;
}
- if (strncasecmp(argv[0], "DTR", strlen(argv[0])) == 0) {
+ if (strncasecmp(argv[i], "DTR", strlen(argv[i])) == 0) {
#ifdef TIOCM_DTR
if (flag) {
control |= TIOCM_DTR;
@@ -1011,7 +1012,7 @@ TtySetOptionProc(instanceData, interp, optionName, value)
ckfree((char *) argv);
return TCL_ERROR;
#endif /* TIOCM_DTR */
- } else if (strncasecmp(argv[0], "RTS", strlen(argv[0])) == 0) {
+ } else if (strncasecmp(argv[i], "RTS", strlen(argv[i])) == 0) {
#ifdef TIOCM_RTS
if (flag) {
control |= TIOCM_RTS;
@@ -1023,7 +1024,7 @@ TtySetOptionProc(instanceData, interp, optionName, value)
ckfree((char *) argv);
return TCL_ERROR;
#endif /* TIOCM_RTS*/
- } else if (strncasecmp(argv[0], "BREAK", strlen(argv[0])) == 0) {
+ } else if (strncasecmp(argv[i], "BREAK", strlen(argv[i])) == 0) {
#ifdef SETBREAK
SETBREAK(fsPtr->fd, flag);
#else /* !SETBREAK */
@@ -1033,15 +1034,14 @@ TtySetOptionProc(instanceData, interp, optionName, value)
#endif /* SETBREAK */
} else {
if (interp) {
- Tcl_AppendResult(interp,
- "bad signal for -ttycontrol: must be ",
+ Tcl_AppendResult(interp, "bad signal \"", argv[i],
+ "\" for -ttycontrol: must be ",
"DTR, RTS or BREAK", (char *) NULL);
}
ckfree((char *) argv);
return TCL_ERROR;
}
- argc -= 2, argv += 2;
- } /* while (argc > 1) */
+ } /* -ttycontrol options loop */
SETCONTROL(fsPtr->fd, &control);
ckfree((char *) argv);