Overview
Features
Download
Documentation
Community
Add-Ons & Services

FTP connection - assertion fails

Please post support and help requests here.

FTP connection - assertion fails

Postby master666 » 12 Jan 2010, 16:49

Hi,

I am new to POCO.

My Task: Establish a connection to a given FTP server and download weather information files "TAFs" (*.txt, ASCII).

The server to connect to is "tgftp.nws.noaa.gov" (logging in as "anonymous" w/o pw) - however in VS2008 compiling in debug mode an assertion strikes when executing.

Connecting to another server works (made an ftp connection to the server where my HP is located).

The code (hope I figured out things right since there is not a c/p example for FTP available).

I (hopefully) figured out that
Code: Select all
session.getWorkingDirectory()
is the statement the assertion comes from.

Code: Select all
FTPClientSession session("tgftp.nws.noaa.gov");

session.login("anonymous", "");

session.setWorkingDirectory( "data" );

cout << "Working dir" << session.getWorkingDirectory() << endl;

session.close();


Many thanks for any helpful replies.


Regards,
--eric
master666
 
Posts: 3
Joined: 12 Jan 2010, 15:59

Re: FTP connection - assertion fails

Postby guenter » 15 Jan 2010, 10:39

It seems, that you've found a bug in getWorkingDirectory(). FTPClientSession::extractPath(), which is used by getWorkingDirectory() to extract the path information from the FTP server response has a bug in its double double quote handling code.

If you change FTPClientSession::extractPath() as follows, this should work again.

Code: Select all
std::string FTPClientSession::extractPath(const std::string& response)
{
   std::string path;
   std::string::const_iterator it  = response.begin();
   std::string::const_iterator end = response.end();
   while (it != end && *it != '"') ++it;
   if (it != end)
   {
      ++it;
      while (it != end)
      {
         if (*it == '"')
         {
            ++it;
            if (it == end || (it != end && *it != '"')) break;
         }
         path += *it++;
      }
   }
   return path;
}


I have created a bug report. Will be fixed in the 1.3.6p2 release.
guenter
 
Posts: 1119
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests