summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixChan.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-11-17 02:52:24 (GMT)
committerhobbs <hobbs>2004-11-17 02:52:24 (GMT)
commitb70f7a0c3c837a92e17bb6ec8214cb77b4d2a670 (patch)
tree87beaefa136c417281c210ccd24849b78b543f9f /unix/tclUnixChan.c
parentc2f5a2c1c0eca7207fea7c2945ba25d7e94e927e (diff)
downloadtcl-b70f7a0c3c837a92e17bb6ec8214cb77b4d2a670.zip
tcl-b70f7a0c3c837a92e17bb6ec8214cb77b4d2a670.tar.gz
tcl-b70f7a0c3c837a92e17bb6ec8214cb77b4d2a670.tar.bz2
* unix/tclUnixChan.c (TtySetOptionProc): fixed crash configuring
-ttycontrol on a channel. [Bug 1067708]
Diffstat (limited to 'unix/tclUnixChan.c')
-rw-r--r--unix/tclUnixChan.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index b7f0339..b875e08 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.42.2.3 2004/05/04 03:50:59 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.42.2.4 2004/11/17 02:52:25 hobbs Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
@@ -997,6 +997,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;
}
@@ -1011,12 +1012,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;
@@ -1028,7 +1029,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;
@@ -1040,7 +1041,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 */
@@ -1050,15 +1051,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);