cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: FTP upload problems with libcurl 7.9

From: Nielsen Linus (ext) <Linus.Nielsen_at_elema.siemens.se>
Date: Mon, 15 Oct 2001 10:17:35 +0200

Hi!

I have seen this problem before. Back then, the person that tried
to use ftpupload.c to upload a file didn't check that the file
could be opened locally:

  hd_src = fopen(LOCAL_FILE, "rb");

Are you really sure that this fopen() is successful?

You should check the file handle afterwards:

  if(!hd_src) {
    fprintf(stderr, "Couldn't open %s\n", LOCAL_FILE);
    exit(1);
  }

If you don't do this, you might pass an invalid file handle to
curl, and you will get a violation of some kind.

(BTW, this check is intentionally left out of the example code
to make it easier to read.)

/Linus

> -----Original Message-----
> From: Extern Caron-Fauriat Stéphanie (Tenovis;PN-SYS/DAC)
> [mailto:Stephanie.Caron-Fauriat_at_tenovis.com]
> Sent: den 12 oktober 2001 17:01
> To: 'curl-library_at_lists.sourceforge.net'
> Subject: FTP upload problems with libcurl 7.9
>
>
>
> Hello,
>
> I built the libcurl 7.9 using curllib.dsp with VC6 and
> everything was OK (I just had to add Ws2_32.lib to the used lib).
> Now I'm trying to make the ftpupload program to work.
> I made a VC6 project with only the ftpuload.c file, linking
> with the liburl.lib.
> To build this project, I had to add
> #include <sys/stat.h>
> #include <fcntl.h>
> at the beginning of ftpupload.c.
>
> My FTP server does not allow anonymous connection so, I add
> curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:xxx");
>
> Then, when I execute the program I have a memory violation.
> I put the option CURLOPT_VERBOSE, and here is the end of the
> log I obtained (ZZZZ is the address of the server):
> ...
> * Connected the data stream!< 220 ZZZZ FTP server (Version
> 6.4/OpenBSD/Linux-ftpd-0.16)
> ready
> > TYPE I
> < 200 Type set to I.
> > STOR while-uploading.txt
> < 150 Opening BINARY mode data connection for 'while-uploading.txt'.
>
> The file while-updating.txt was created on the server but is empty.
>
> I think I missed something... Could you help me?
>
> Thanks in advance,
>
> Stéphanie
>
>
Received on 2001-10-15