On Mon, Sep 26, 2005 at 02:01:14PM -0500, Douglas Mueller wrote:
> I believe I have discovered a bug. With your client I am unable to
> transfer a 0 byte file when 'set ssl-protect-data yes' is set. I have
> been able to send this file with different ftp clients. Below I have
> include my log file.
Does this patch (for lftp-3.3.0) help?
--
Alexander. | http://www.yars.free.net/~lav/
Index: ChangeLog
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/ChangeLog,v
retrieving revision 1.954
diff -u -p -r1.954 ChangeLog
--- ChangeLog 26 Sep 2005 12:18:55 -0000 1.954
+++ ChangeLog 27 Sep 2005 13:34:51 -0000
@@ -1,3 +1,11 @@
+2005-09-27 Alexander V. Lukyanov <[EMAIL PROTECTED]>
+
+ * lftp_ssl.h: make handshake_done public.
+ * lftp_ssl.cc: do_handshake even when writing no data.
+ * buffer_ssl.cc, buffer_ssl.h: call ssl->write even with no data
+ when handshake is not done yet; (Done) check handshake_done -
+ this fixes a bug with uploading empty files.
+
2005-09-26 Alexander V. Lukyanov <[EMAIL PROTECTED]>
* Http.cc: simplify path combination; pre-encode %2F for hftp.
Index: buffer_ssl.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/buffer_ssl.cc,v
retrieving revision 1.7
diff -u -p -r1.7 buffer_ssl.cc
--- buffer_ssl.cc 29 Apr 2005 10:31:35 -0000 1.7
+++ buffer_ssl.cc 27 Sep 2005 11:27:58 -0000
@@ -39,7 +39,7 @@ int IOBufferSSL::Do()
switch(mode)
{
case PUT:
- if(in_buffer==0)
+ if(in_buffer==0 && ssl->handshake_done)
return STALL;
res=Put_LL(buffer+buffer_ptr,in_buffer);
if(res>0)
Index: buffer_ssl.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/buffer_ssl.h,v
retrieving revision 1.5
diff -u -p -r1.5 buffer_ssl.h
--- buffer_ssl.h 18 May 2005 05:57:08 -0000 1.5
+++ buffer_ssl.h 27 Sep 2005 11:19:45 -0000
@@ -42,6 +42,7 @@ public:
IOBufferSSL(lftp_ssl *s,dir_t m);
void CloseLater() { close_later=true; }
int Do();
+ bool Done() { return IOBuffer::Done() && ssl->handshake_done; }
};
#endif
Index: lftp_ssl.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/lftp_ssl.cc,v
retrieving revision 1.22
diff -u -p -r1.22 lftp_ssl.cc
--- lftp_ssl.cc 7 Sep 2005 06:07:42 -0000 1.22
+++ lftp_ssl.cc 27 Sep 2005 11:26:04 -0000
@@ -555,6 +555,8 @@ int lftp_ssl_gnutls::write(const char *b
int res=do_handshake();
if(res!=DONE)
return res;
+ if(size==0)
+ return 0;
errno=0;
res=gnutls_record_send(session,buf,size);
if(res<0)
@@ -896,6 +898,8 @@ int lftp_ssl_openssl::write(const char *
int res=do_handshake();
if(res!=DONE)
return res;
+ if(size==0)
+ return 0;
errno=0;
res=SSL_write(ssl,buf,size);
if(res<0)
Index: lftp_ssl.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/lftp_ssl.h,v
retrieving revision 1.17
diff -u -p -r1.17 lftp_ssl.h
--- lftp_ssl.h 25 May 2005 13:27:17 -0000 1.17
+++ lftp_ssl.h 27 Sep 2005 11:19:20 -0000
@@ -32,10 +32,8 @@
class lftp_ssl_base
{
-protected:
- bool handshake_done;
-
public:
+ bool handshake_done;
int fd;
char *hostname;
enum handshake_mode_t { CLIENT, SERVER } handshake_mode;