Version 5 of gets

Updated 2001-11-13 19:13:23

gets - Read a single line from a channel http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/get.htm

  gets channelId
  gets channelId variable

Reads a single line from the specified channel. In the first form the characters of the line (with the exception of the end-of-line character) are returned as the result of the command. In the second form the characters of the line are written into the variable and the length of the line is returned instead.

When applied to a blocking channel the command will block until a line is complete or EOF was encountered. If the command is applied to a non-blocking channel and unable to read a complete line the first form of the command will return an empty string. The second form will return a -1 and refrain from setting the variable.

Do not use this command when Working with binary data. It will try to recognize end-of-line characters no matter what, even inside of packets.


From the Tcl'ers chat on Oct 24, 2001:

dgp: I reported long ago that tclhttpd was vulnerable to a DoS due to gets slurping up data until it sees a newline. I guess that weakness in gets has never been addressed.

bbh: is it a weakness in gets or a weakness in an app using gets instead of read ?

dgp: Well, Brent Welch replied and said that the solution he would have to implement would be effectively writing his own safe gets in terms of read.


Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command from Tcl