touch -t

Version:

7.6 (fixed in 8.0)

How it is diagnosed (reproduced or source analysis)?

Reproduced

How to reproduce?

coreutils-7.6/src/touch -t 08080808.60 XXX

../../../coreutils-7.6/src/touch: invalid date format `08080808.60'

Symptom:

Early termination by rejecting valid input.

.60 -- leap second, should be allowed.

Root cause:

Developers simply did not consider this case...

182 /* Parse a POSIX-style date, returning true if successful.  */

183

184 bool

185 posixtime (time_t *p, const char *s, unsigned int syntax_bits)

186 {

    .. .. ..

    /* tm0.tm_sec == 60 */

210   /* Reject dates like "September 31" and times like "25:61".  */

211   if ((tm0.tm_year ^ tm->tm_year)

212       | (tm0.tm_mon ^ tm->tm_mon)

213       | (tm0.tm_mday ^ tm->tm_mday)

214       | (tm0.tm_hour ^ tm->tm_hour)

215       | (tm0.tm_min ^ tm->tm_min)

216       | (tm0.tm_sec ^ tm->tm_sec))

217     return false;

This return value will eventually result in the error message here:

main (.. )

{

 .. .. ..

 switch (c)

323         case 't':

324           if (! posixtime (&newtime[0].tv_sec, optarg,

325                            PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS))

326             error (EXIT_FAILURE, 0, _("invalid date format %s"),

327                    quote (optarg));

}

/* In the correct version (8.0), add an additional check whether tm0.tm_sec

  is 60.  */

210   /* Reject dates like "September 31" and times like "25:61".

211 +     Do not reject times that specify "60" as the number of seconds.  */

212   if ((tm0.tm_year ^ tm->tm_year)

213       | (tm0.tm_mon ^ tm->tm_mon)

214       | (tm0.tm_mday ^ tm->tm_mday)

215       | (tm0.tm_hour ^ tm->tm_hour)

216       | (tm0.tm_min ^ tm->tm_min)

217       | (tm0.tm_sec ^ tm->tm_sec))

218     {  

219       /* Any mismatch without 60 in the tm_sec field is invalid.  */

220+       if (tm0.tm_sec != 60)

221         return false;

222+        

223+      {  

224+         /* Allow times like 01:35:60 or 23:59:60.  */

225+         time_t dummy;

226+         char buf[16];

227+         char *b = stpcpy (buf, s);

228+         strcpy (b - 2, "59");

229+         if (!posixtime (&dummy, buf, syntax_bits))

230+           return false;

231+       }

232     }

Is there Error Message?

Yes. Checking input.

Can Errlog automatically insert this msg?

No. This msg is domain specific...