wxFTP::PWD() error Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

wxFTP::PWD() error

Post by Oleg »

I am going to use wxFTP to connect to ftp server and get current working directory with this code:

Code: Select all

	wxFTP ftp;
	ftp.SetUser(wxT("username"));
	ftp.SetPassword(wxT("password"));

	if (ftp.Connect("ipaddres"))
	{
		std::cout << "Connected" << std::endl;
		wxString str = ftp.Pwd(); <<------- ERROR: string iterator not dereferencable
	}
But when i use

Code: Select all

ftp.Pwd()
i have error (see screenshot). What am i doing wrong?
error.png
error.png (12.36 KiB) Viewed 31229 times
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

Error occurred at:

Code: Select all

wxString wxFTP::Pwd()
{
    wxString path;

    if ( CheckCommand(wxT("PWD"), '2') )
    {
        // the result is at least that long if CheckCommand() succeeded
        wxString::const_iterator p = m_lastResult.begin() + LEN_CODE + 1;
        if ( *p != wxT('"') )
        {
            wxLogDebug(wxT("Missing starting quote in reply for PWD: %s"),
                       wxString(p, m_lastResult.end()));
        }
        else
        {
            for ( ++p; *p; ++p )
            {
                if ( *p == wxT('"') )
                {
                    // check if the quote is doubled
                    ++p;
                    if ( !*p || *p != wxT('"') ) <<----------- ERROR: string iterator not dereferencable WTF???
                    {
                        // no, this is the end
                        break;
                    }
                    //else: yes, it is: this is an embedded quote in the
                    //      filename, treat as normal char
                }

                path += *p;
            }

            if ( !*p )
            {
                wxLogDebug(wxT("Missing ending quote in reply for PWD: %s"),
                           m_lastResult.c_str() + LEN_CODE + 1);
            }
        }
    }
    else
    {
        m_lastError = wxPROTO_PROTERR;
        wxLogDebug(wxT("FTP PWD command failed."));
    }

    return path;
}
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax »

If you break into the debugger, what does "m_lastResult" contain?
Use the source, Luke!
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

@doublemax that is what i have:
last error.png
last error.png (34.1 KiB) Viewed 31201 times
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax »

What does "p" point to at the moment of the crash?

It looks that the ftp server returns something the parser is not prepared for. If that's the case, please open a bug report at: http://trac.wxwidgets.org
Use the source, Luke!
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

After that step program is going to crash:
ppointer.png
ppointer.png (30.73 KiB) Viewed 31194 times
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax »

It's a little hard to tell what exactly is going on without being able to trace through it myself. But i looks like a bug in the parsing code. So i'd suggest to open a bug report.
Use the source, Luke!
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

Ok, thanks.
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax »

Thanks. I wouldn't expect a fix anytime soon. So you better find a workaround or try to fix it yourself.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxFTP::PWD() error

Post by ONEEYEMAN »

Oleg,
What's you OS/compiler/wx version?
Can you step inside the offending function and see where exactly the crash occurred?

Thank you.
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

OS: Windows 7 Professional x64
Compiler: Microsoft Visual Studio 2013
wxVersion: wxWidgets-3.1.0
ONEEYEMAN wrote:Can you step inside the offending function and see where exactly the crash occurred?
Yes, at this point:
ppointer.png
ppointer.png (30.73 KiB) Viewed 31160 times
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax »

Use the source, Luke!
User avatar
Oleg
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed May 25, 2016 8:07 pm
Location: Ukraine

Re: wxFTP::PWD() error

Post by Oleg »

Great! Thanks.
Post Reply