cURL / Mailing Lists / curl-library / Single Mail

curl-library

sftp file upload doesn't truncate file

From: Kristian Gunstone <kristian.gunstone_at_pean.org>
Date: Wed, 9 May 2007 16:58:26 +0200

Hello again!

I just noticed another problem, now regarding sftp upload.

If I upload a file via sftp, but the file already exists on the remote
host, libcurl will not truncate it. It will just overwrite the number of
bytes specified with CURLOPT_INFILESIZE from the beginning of the file.

I solved this by changing lib/ssh.c:726 from
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT
to
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC

This will correctly truncate the file.

I also made a diff of it which can be located here:

http://www.pulia.nu/code/junk/curl-lib_ssh_c-sftp_upload_truncate_fix.diff

Cheers,

-- 
Kristian Gunstone
http://www.pulia.nu
Received on 2007-05-09