Re: possible bug in site utime

"Alexander V. Lukyanov" <[email protected]>
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
On Thu, Jan 06, 2005 at 10:17:57AM +0100, Pierre Chifflier wrote:
> * it seems lftp 3.0.13 (current debian unstable version) sends garbage
> at the end of each date/time string:
>
> (displayed on lftp)
> ---> SITE UTIME NOTES 200501060905 H 200501060905 H 200501060905 H UTC
>
> (received by server)
> <- 'SITE UTIME NOTES 200501060905 ???H 200501060905 ???H 200501060905
> ???H UTC'

Here is a fix.

--
   Alexander.
diff (text/plain, 1.4 KB)
Index: ftpclass.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/ftpclass.cc,v
retrieving revision 1.344
retrieving revision 1.346
diff -u -p -r1.344 -r1.346
--- ftpclass.cc	16 Dec 2004 12:59:56 -0000	1.344
+++ ftpclass.cc	11 Jan 2005 06:59:29 -0000	1.346
@@ -18,7 +18,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* $Id: ftpclass.cc,v 1.344 2004/12/16 12:59:56 lav Exp $ */
+/* $Id: ftpclass.cc,v 1.346 2005/01/11 06:59:29 lav Exp $ */
 
 #include <config.h>
 
@@ -2408,17 +2408,20 @@ void Ftp::SendUTimeRequest()
    {
       char *c=string_alloca(11+strlen(file)+14*3+3+4);
       char d[15];
-      time_t n=now;
-      strftime(d,sizeof(d)-1,"%Y%m%d%H%M%S",gmtime(&n));
+      time_t n=entity_date;
+      strftime(d,sizeof(d),"%Y%m%d%H%M%S",gmtime(&n));
+      d[sizeof(d)-1]=0;
       sprintf(c,"SITE UTIME %s %s %s %s UTC",file,d,d,d);
       conn->SendCmd(c);
       expect->Push(Expect::SITE_UTIME);
    }
    else if(QueryBool("use-mdtm-overloaded"))
    {
-      char *c=string_alloca(5+14+1);
-      time_t n=now;
-      strftime(c,19,"MDTM %Y%m%d%H%M%S",gmtime(&n));
+      const int c_size=5+14+1;
+      char *c=string_alloca(c_size);
+      time_t n=entity_date;
+      strftime(c,c_size,"MDTM %Y%m%d%H%M%S",gmtime(&n));
+      c[c_size-1]=0;
       conn->SendCmd2(c,file);
       expect->Push(Expect::IGNORE);
    }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.