Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-89 [net] TelnetClient broken for binary transmissions + solution
  3. NET-329

TelnetInoutStream#__read() bug in the __receiveState handling for the _STATE_IAC state.

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None

      Description

      Moved from NET-89:

      Also, in TelnetInputStream#__read() there is a bug in the __receiveState
      handling for the _STATE_IAC state. When a second consecutive IAC (0x255) is
      received to encode the single 0x255 character, read does not return 0x255 but
      instead move on to reading the next char in the stream.

      The current code reads:

      case _STATE_IAC:
          switch (ch)
          {
          case TelnetCommand.WILL:
              __receiveState = _STATE_WILL;
              continue;
          case TelnetCommand.WONT:
              __receiveState = _STATE_WONT;
              continue;
          case TelnetCommand.DO:
              __receiveState = _STATE_DO;
              continue;
          case TelnetCommand.DONT:
              __receiveState = _STATE_DONT;
              continue;
          /* TERMINAL-TYPE option (start)*/
          case TelnetCommand.SB:
              __suboption_count = 0;
              __receiveState = _STATE_SB;
              continue;
          /* TERMINAL-TYPE option (end)*/
          case TelnetCommand.IAC:
              __receiveState = _STATE_DATA;
              break;
          default:
              break;
          }
          __receiveState = _STATE_DATA;
          continue;
      case _STATE_WILL:
      

      but it should be:

      case _STATE_IAC:
          switch (ch)
          {
          case TelnetCommand.WILL:
              __receiveState = _STATE_WILL;
              continue;
          case TelnetCommand.WONT:
              __receiveState = _STATE_WONT;
              continue;
          case TelnetCommand.DO:
              __receiveState = _STATE_DO;
              continue;
          case TelnetCommand.DONT:
              __receiveState = _STATE_DONT;
              continue;
          /* TERMINAL-TYPE option (start)*/
          case TelnetCommand.SB:
              __suboption_count = 0;
              __receiveState = _STATE_SB;
              continue;
          /* TERMINAL-TYPE option (end)*/
          case TelnetCommand.IAC:
              __receiveState = _STATE_DATA;
              break; // exit to enclosing switch to return from read
          default:
              __receiveState = _STATE_DATA;           
              continue; // move on the next char
          }
          break; // exit and return from read
      case _STATE_WILL:
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: