Issue Details (XML | Word | Printable)

Key: NET-173
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Unassigned
Reporter: Scott Burch
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()

Created: 07/Nov/07 04:37 PM   Updated: 05/Feb/09 06:40 PM
Return to search
Component/s: None
Affects Version/s: 1.4
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Linux
Issue Links:
Reference
 

Resolution Date: 05/Feb/09 06:40 PM


 Description  « Hide
TelnetOutputStream.java appears to have a bug that if we send a IAC to the stream returned by TelnetClient.getOutputStream() we get duplicate IAC commands to the telnet server.

I looked through the code and I think I have found the reason.

Line 82-85 appears to just send two IAC commands.
82 case TelnetCommand.IAC:
83 __client._sendByte(TelnetCommand.IAC);
84 __client._sendByte(TelnetCommand.IAC);
85 break;

Line 91-95 appears to send the original character (which is a IAC) and a IAC thus producing two IACs in the stream.
91 else if (ch == TelnetCommand.IAC)
92 { 93 __client._sendByte(ch); 94 __client._sendByte(TelnetCommand.IAC); 95 }



50 public void write(int ch) throws IOException
51 {
52
53 synchronized (__client)
54 {
55 ch &= 0xff;
56
57 if (__client._requestedWont(TelnetOption.BINARY))
58 {
59 if (__lastWasCR)
60 {
61 if (__convertCRtoCRLF)this
62 {
63 __client._sendByte('\n');
64 if (ch == '\n')
65 { 66 __lastWasCR = false; 67 return ; 68 }
69 }
70 else if (ch != '\n')
71 __client._sendByte('\0');
72 }
73
74 __lastWasCR = false;
75
76 switch (ch)
77 { 78 case '\r': 79 __client._sendByte('\r'); 80 __lastWasCR = true; 81 break; 82 case TelnetCommand.IAC: 83 __client._sendByte(TelnetCommand.IAC); 84 __client._sendByte(TelnetCommand.IAC); 85 break; 86 default: 87 __client._sendByte(ch); 88 break; 89 }
90 }
91 else if (ch == TelnetCommand.IAC)
92 {93 __client._sendByte(ch);94 __client._sendByte(TelnetCommand.IAC);95 } }
96 else
97 __client._sendByte(ch);
98 }
99 }



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sebb made changes - 16/May/08 04:28 PM
Field Original Value New Value
Link This issue is related to NET-89 [ NET-89 ]
Rory Winston made changes - 05/Feb/09 06:40 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]