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 » Thu Sep 22, 2016 8:16 pm

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 4248 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 » Thu Sep 22, 2016 8:38 pm

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: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFTP::PWD() error

Post by doublemax » Thu Sep 22, 2016 11:03 pm

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 » Fri Sep 23, 2016 8:06 am

@doublemax that is what i have:
last error.png
last error.png (34.1 KiB) Viewed 4220 times

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

Re: wxFTP::PWD() error

Post by doublemax » Fri Sep 23, 2016 9:42 am

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 » Fri Sep 23, 2016 10:30 am

After that step program is going to crash:
ppointer.png
ppointer.png (30.73 KiB) Viewed 4213 times

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

Re: wxFTP::PWD() error

Post by doublemax » Fri Sep 23, 2016 11:22 am

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 » Fri Sep 23, 2016 11:24 am

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 » Fri Sep 23, 2016 12:32 pm


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

Re: wxFTP::PWD() error

Post by doublemax » Fri Sep 23, 2016 1:56 pm

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: 3402
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxFTP::PWD() error

Post by ONEEYEMAN » Fri Sep 23, 2016 2:11 pm

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 » Fri Sep 23, 2016 2:26 pm

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 4179 times

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

Re: wxFTP::PWD() error

Post by doublemax » Mon Sep 26, 2016 7:21 am

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 » Mon Sep 26, 2016 7:32 am

Great! Thanks.

Post Reply