Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-442

StringIndexOutOfBoundsException: String index out of range: -1 if server respond with root is current directory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.2
    • FTP
    • None
    • Ubuntu linux 11.04

    Description

      I've an ftp server that at the pwd request responds with |257 root is current directory.| without any double quotes present and the lib gives up with this exception:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1949)
      at org.apache.commons.net.ftp.FTPClient.__parsePathname(FTPClient.java:469)
      at org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:2374)

      Probably it's only needed a check in __parsePathname

      private String __parsePathname(String reply)
      {
      int begin, end;

      begin = reply.indexOf('"') + 1;
      end = reply.indexOf('"', begin);

      if (begin == -1 && end == -1)

      { return reply; }

      return reply.substring(begin, end);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            andrews7up Andrea Selva
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: