You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Scott Burch (JIRA)" <ji...@apache.org> on 2007/11/07 17:37:50 UTC
[jira] Created: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
---------------------------------------------------------------------
Key: NET-173
URL: https://issues.apache.org/jira/browse/NET-173
Project: Commons Net
Issue Type: Bug
Affects Versions: 1.4
Environment: Linux
Reporter: Scott Burch
Priority: Blocker
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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Scott Burch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597553#action_12597553 ]
Scott Burch commented on NET-173:
---------------------------------
Thank you for sending that.
Now, I think I know where the confusion is. What I was trying to do was send a command. I think what that part of the RFC was talking about was escaping 0xFF characters.
What I could not find was a way to send a command because (if I remember right) the stacks were hard wired together and could not be broken apart.
So, what I tried to do was send a IAC-COMMAND and what was coming out was IAC-IAC-COMMAND which the other end recognized as a IAC-0xFF substituting the second IAC for command. Then getting my COMMAND as data
I could not find a way around this, so we went with a different library.
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Scott Burch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597557#action_12597557 ]
Scott Burch commented on NET-173:
---------------------------------
If sending commands is not part of the library. Then yes. I now understand why my first assumption was wrong.
Unless you know of a way to send a command that I could not find.
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Scott Burch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597539#action_12597539 ]
Scott Burch commented on NET-173:
---------------------------------
That is not a very good work around because then it will not work with terminals that conform to the standards. Breaking the standards on both ends is not a solution. I had problems talking to a mini computer not running this stack.
The best solution is to fix this so that it sends the right commands to match the RFC.
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Rory Winston (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rory Winston closed NET-173.
----------------------------
Resolution: Fixed
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Rory Winston (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572412#action_12572412 ]
Rory Winston commented on NET-173:
----------------------------------
Can you supply a patch for this?
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597550#action_12597550 ]
Sebb commented on NET-173:
--------------------------
AFAIK, the Telnet standard is RFC854: http://www.ietf.org/rfc/rfc854.txt.
This says in section "TELNET COMMAND STRUCTURE" top of page 14:
{quote}
inefficiency, of "escaping" the data bytes into the stream. With the
current set-up, only the IAC need be doubled to be sent as data, and
the other 255 codes may be passed transparently."
{quote}
This is presumably the reason for the doubling seen in TelnetOutputStream.java
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597555#action_12597555 ]
Sebb commented on NET-173:
--------------------------
So can this issue be closed?
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (NET-173) Duplicate IAC when sending a IAC using
TelnetClient.getOutputStream()
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/NET-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597535#action_12597535 ]
Sebb commented on NET-173:
--------------------------
Surely the IAC character is used as an escape character and a command introducer?
So I think it needs to be duplicated.
> Duplicate IAC when sending a IAC using TelnetClient.getOutputStream()
> ---------------------------------------------------------------------
>
> Key: NET-173
> URL: https://issues.apache.org/jira/browse/NET-173
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux
> Reporter: Scott Burch
> Priority: Blocker
>
> 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 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.