Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 23 Apr 2012 12:13:13 +0400
From: "Alexander V. Lukyanov" <lav@...is.ru>
To: Solar Designer <solar@...nwall.com>
Cc: owl-dev@...ts.openwall.com
Subject: Re: lftp update

On Sun, Apr 22, 2012 at 11:49:35PM +0400, Solar Designer wrote:
> > This patch is about "Inaccurate timestamps" (
> > https://bugzilla.redhat.com/show_bug.cgi?id=666580). This situation occurs
> > always. So I want to add this patch into the package.
> 
> Yes, but that patch is a dirty hack, which will have side-effects: the
> time_fmt string doesn't have to consist solely of format specifiers, it
> may also contain arbitrary text, so with that patch behavior might
> differ depending on whether e.g. an English word contains one of the
> letters matching the format specifiers being checked for or not.
> 
> The patch proposed by JW on the bug entry above makes more sense to me:
> it fixes only one aspect of the issue (adds "%s"), but at least it
> doesn't make things worse in any other aspect (as far as I am aware).
> 
> JW suggests that lftp should keep the maximum possible timestamp
> precision in all cases, which sounds right to me, but I don't know why
> that need_exact_time thing exists in lftp in the first place (nor did I
> try to find out why).  There ought to be a reason for that, so simply
> patching it to "need_exact_time=true;" without figuring that out would
> also be wrong.  (I guess this might have to do with extra round-trips
> being needed to request the exact time with certain protocols - e.g.,
> the usual ls-like listings via FTP vs. the MDTM command.  So maybe the
> protocol in use should be taken into consideration.)

cls command does not need to output precise time always, so it is possible
to optimize it by allowing backend not to try to get exact time when
getting exact time is expensive.

There would be no harm if need_exact_time will be true when it may be false,
cls would only spend more time getting unneeded info.

So I think the simplest thing is to set need_exact_time always when the time
is needed at all. Please test this patch.

-- 
   Alexander.

diff --git a/src/commands.cc b/src/commands.cc
index 87c74bc..17d9def 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -1528,6 +1528,8 @@ const char *FileSetOutput::parse_argv(const Ref<ArgV>& a)
 
    time_fmt.set(0);
    if(time_style && time_style[0]) {
+      if (mode & DATE)
+	 need_exact_time=true;
       if(time_style[0]=='+')
 	 time_fmt.set(time_style+1);
       else if(!strcmp(time_style,"full-iso"))
@@ -1539,20 +1541,6 @@ const char *FileSetOutput::parse_argv(const Ref<ArgV>& a)
 	 time_fmt.set("%Y-%m-%d \n%m-%d %H:%M");
       else
 	 time_fmt.set(time_style);
-      need_exact_time=false;
-      if(time_fmt) {
-	 static const char exact_fmts[][3]={"%H","%M","%S","%N",""};
-	 int sep=strcspn(time_fmt,"\n|");
-	 for(int i=0; exact_fmts[i][0]; i++) {
-	    const char *f=strstr(time_fmt,exact_fmts[i]);
-	    if(!f)
-	       continue;
-	    if(i>1 || sep>f-time_fmt) {
-	       need_exact_time=true;
-	       break;
-	    }
-	 }
-      }
    }
 
    // remove parsed options.

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ