gets returns crap on tls-channels
Closed / Fixed1869405fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-01-11 15:43:16
Command "gets" in tcl8.5 returns invalid data when reading from a tls-channel in binary mode.
Tcl8.4.16 returns valid data.
example:
##############################################
# start a ssl server with
openssl s_server -cert cert.pem -key key.pem -www
##############################################
# run the following tcl script:
package require tls
set chan [::tls::socket 127.1 4433]
puts -nonewline $chan "GET / HTTP/1.0\r\n"
flush $chan
fconfigure $chan -encoding binary -translation binary
while {[gets $chan LINE] >= 0} {puts $LINE}
###############################################
fompplain2008-01-20 08:47:53
Logged In: YES user_id=411868 Originator: NO TclGetsObjBinary doesn't use the TopChan. The following patch fixes this.
fompplain2008-01-20 08:53:08
Logged In: YES
user_id=411868
Originator: NO
ups, forgot the patch...
--- generic/tclIO.c 13 Dec 2007 15:23:17 -0000 1.136
+++ generic/tclIO.c 20 Jan 2008 01:14:09 -0000
@@ -3953,12 +3953,6 @@
char *dst, *dstEnd, *eol, *eof;
Tcl_EncodingState oldState;
- /*
- * This operation should occur at the top of a channel stack.
- */
-
- chanPtr = statePtr->topChanPtr;
-
if (CheckChannelErrors(statePtr, TCL_READABLE) != 0) {
copiedTotal = -1;
goto done;
@@ -3976,6 +3970,12 @@
return TclGetsObjBinary(chan, objPtr);
}
+ /*
+ * This operation should occur at the top of a channel stack.
+ */
+
+ chanPtr = statePtr->topChanPtr;
+
bufPtr = statePtr->inQueueHead;
encoding = statePtr->encoding;
@@ -4319,6 +4319,12 @@
bufPtr = statePtr->inQueueHead;
/*
+ * This operation should occur at the top of a channel stack.
+ */
+
+ chanPtr = statePtr->topChanPtr;
+
+ /*
* Preserved so we can restore the channel's state in case we don't find a
* newline in the available input.
*/
hobbsplain2008-01-21 04:16:40
Logged In: YES user_id=72656 Originator: NO Fixed for 8.5.1.
Log in (anonymous is fine) to add a comment.