cURL / Mailing Lists / curl-library / Single Mail

curl-library

Possible libcurl bugs

From: Peter Soxberger <Peter.Soxberger_at_gmx.net>
Date: Sat, 19 Sep 2009 11:37:20 +0200

Hi!

I'm not sure, but it seems like the following problems are bugs in libcur.

I'm working on a ftp upload function and I always run into the same two problems:

1) If I use fopen() before calling curl_easy_setopt(easyhandle,CURLOPT_PASSWORD,password); I always get a crash.
Ok, the workaround is easy because I only have to place the fopen() after the mentioned line.

2) If I use CURLOPT_VERBOSE with the ftp upload function, libcurl always tries to write at position 0x00000000 => application crashes
I found no working workaround!
When downloading a file from an ftp server I can use CURLOPT_VERBOSE without any problems...

libcurl version: 7.19.3
running on Win XP 32bit
IDE: VC++ 2008

Here is the source of the function (maybe I'm only overlooking something?):

//------------------------------------------------------------------------
        CURL* easyhandle;

        //Checks if there is already another transfer running
        if(ftp_file.filename != NULL) return -1;

        //curl handle for the ftp client
        easyhandle = curl_easy_init();
        if(!easyhandle) return -1;

        curl_easy_setopt(easyhandle,CURLOPT_READFUNCTION,ftp_read_callback); //setzt die Callbackfunktion
        curl_easy_setopt(easyhandle,CURLOPT_UPLOAD,1L); //Upload
        curl_easy_setopt(easyhandle,CURLOPT_URL,url); //URL+Filename
        curl_easy_setopt(easyhandle,CURLOPT_USERNAME,username); //Setzt den Usernamen
        curl_easy_setopt(easyhandle,CURLOPT_PASSWORD,password); //Setzt das Passwort
        
        //If I place the fopen() before setting up the password, the application crashes!

        //opens the file
        ftp_file.stream = fopen(path,"rb");
        if(ftp_file.stream == NULL) return _VAR(-1);
        //and gets the filelength
        fseek(ftp_file.stream,0,SEEK_END);
        ftp_file.size = ftell(ftp_file.stream);
        fseek(ftp_file.stream,0,SEEK_SET);

        curl_easy_setopt(easyhandle,CURLOPT_READDATA,ftp_file.stream); //Datei die hochgeladen werden soll
        curl_easy_setopt(easyhandle,CURLOPT_INFILESIZE_LARGE,(curl_off_t)ftp_file.size); //Gibt die Dateigröße an
        curl_easy_setopt(easyhandle,CURLOPT_NOPROGRESS,0); //Progress Callback verwenden
        curl_easy_setopt(easyhandle,CURLOPT_PROGRESSFUNCTION,ftp_progress_callback); //setzt die progress Callbackfunktion
        if(ftp_debug_state)
        {
                ftp_file.log_handle = fopen("ftp_log.txt","w");
                if(ftp_file.loghandle == NULL) return -1;
                curl_easy_setopt(easyhandle,CURLOPT_STDERR,ftp_file.log_handle);
                curl_easy_setopt(easyhandle,CURLOPT_VERBOSE,1);
        }

        //Start a thread for performing the request
        CreateThread(NULL,NULL,ftp_perform_thread,(void*)easyhandle,NULL,NULL);
//------------------------------------------------------------------------

Thanks for your help!

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Received on 2009-09-19