#3903 gets returns crap on tls-channels

obsolete: 8.5.0
closed-fixed
5
2008-01-20
2008-01-11
Anonymous
No

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}

###############################################

Discussion

  • Corrado Ficicchia

    Logged In: YES
    user_id=411868
    Originator: NO

    TclGetsObjBinary doesn't use the TopChan.

    The following patch fixes this.

     
  • Corrado Ficicchia

    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.
    */

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2008-01-20
    • assigned_to: andreas_kupries --> hobbs
    • status: open --> closed-fixed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2008-01-20

    Logged In: YES
    user_id=72656
    Originator: NO

    Fixed for 8.5.1.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks