Bug 49173 - Telnet and Rexec tasks are broken on read
Summary: Telnet and Rexec tasks are broken on read
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.8.0
Hardware: All All
: P2 normal (vote)
Target Milestone: 1.8.1
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-22 21:32 UTC by James Wartell
Modified: 2010-04-23 04:36 UTC (History)
0 users



Attachments
proposed patch (1.37 KB, text/plain)
2010-04-22 21:50 UTC, James Wartell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Wartell 2010-04-22 21:32:50 UTC
re: org.apache.tools.ant.taskdefs.optional.net.TelnetTask

The two instances of while-loops currently written like this

while (windowStart++ < 0 
    || !sb.substring(windowStart).equals(s)) {

are wrong. The increment happens before taking the substring. Changing it to this

while (windowStart < 0 
    || !sb.substring(windowStart).equals(s)) {
    windowStart++;

makes it clearer when windowStart is incremented, and makes the code correct. 

Debugging the code while doing the classic case, looking for "ogin:" before typing the username demonstrates that the comparison will be "ogin:" to "gin:" at the iteration when it should break out of the loop, making the loop invariant true.
Comment 1 James Wartell 2010-04-22 21:34:50 UTC
also reported to the mailing list by someone else here:

http://mail-archives.apache.org/mod_mbox/ant-user/201004.mbox/%3Cp2qdedf1a7b1004150751k3324ecf1pff37d2ec91f9b520@mail.gmail.com%3E
Comment 2 James Wartell 2010-04-22 21:50:09 UTC
Created attachment 25337 [details]
proposed patch
Comment 3 Stefan Bodewig 2010-04-23 04:36:33 UTC
Thanks!

This is what you get when you don't have a test environment around.  Should be fixed with svn revision 937187 - but it would be good if you could double check.