cURL / Mailing Lists / curl-library / Single Mail

curl-library

FTP Upload problem : crash

From: <joseph.tilley_at_atxinc.com>
Date: Sat, 20 Nov 2004 12:29:38 -0500

Hello,

I have a program I am developing with curl but am having troubles
uploading a file.

These are the steps I am currently taking in my program. I would
appreciate if anyone could point out any thing I am doing wrong.

OS: WinXP
Curl Version: 7.11.1
IDE: Visual C++ .NET

        char m_szErrMsgLast[1024];
        FILE *pInput = fopen(szLocalFile, "r"); // Open the local file
(C:\tmp.txt would suffice here)
        if (NULL == pInput)
                throw "Unable to open local file";
        long fsize = filelength(fileno (pInput));

        curl_global_init(CURL_GLOBAL_ALL);

        void * m_pCurl = curl_easy_init();

        // set the errror buffer
        curl_easy_setopt(m_pCurl, CURLOPT_ERRORBUFFER, m_szErrMsgLast);

        //Set the passive mode
        curl_easy_setopt(m_pCurl, CURLOPT_FTP_USE_EPSV, TRUE);

        // enable uploading
        curl_easy_setopt(m_pCurl, CURLOPT_UPLOAD, TRUE) ;

        // Set the URL to transmit to (the value of this is
remotefile.txt)
        curl_easy_setopt(m_pCurl, CURLOPT_URL, szRemoteFile);

        // Set a pointer to the file to be sent, and set the size
        curl_easy_setopt(m_pCurl, CURLOPT_INFILE, pInput);
      curl_easy_setopt(m_pCurl, CURLOPT_INFILESIZE, fsize);

        // Want to watch what happens!
        curl_easy_setopt(m_pCurl, CURLOPT_VERBOSE, TRUE);
 
        // Fire away!
        res = curl_easy_perform(m_pCurl);

What results is a crash in curl. The curl_easy_preform call at the end
throws an exception:
(I replaced any identifying information with garbage numbers, but the
messages are untouched.

* About to connect() to 111.22.33.44 port 21
* Connected to 111.22.33.44 (111.22.33.44) port 21
< 220 server.servername.com FTP server (Version wu-2.6.2(9) Mon Jul 21
16:06:46 EDT 2003) ready.
> USER ATXOTST
< 331 Password required for MY_USERNAME
> PASS MY_PWD
< 230 User MY_USERNAME logged in.
* We have successfully logged in
> PWD
< 257 "/abc/def/ghi/jkl" is current directory.
* Entry path is '/abc/def/ghi/jkl'
> CWD in
< 250 CWD command successful.
> PASV
< 227 Entering Passive Mode (111,22,33,44,67,245)
* About to connect() to 111.22.33.44 port 17397
* Connecting to 111.22.33.44 (111.22.33.44) port 17397
* Connected the data stream with PASV!
> TYPE I
< 200 Type set to I.
> STOR ATX_620000582
< 150 Opening BINARY mode data connection for remotefile.txt.

This pauses for a while, I assume the file transfer attempts to take
place.

Then the excetion is thrown:

+ ex { _COMPlusExceptionCode=-532459699
_className="System.NullReferenceException" _exceptionMethod=<undefined
value> ...} System.Exception
+ "System.NullReferenceException: Object reference not set to an
instance of an object.

Any advice at all as to what I may be doing wrone here would be GREATLY
appreciated!

Cheers,
joe

Joe Tilley
E-File Senior Engineer
ATX II, LLC
Phone: (207) 498-4289 ext. 40728
Fax: (207) 498-6838
E-Mail: joseph.tilley_at_atxinc.com
Received on 2004-11-20