[Bug 8951] New: touch -t 197001010000 will use seconds from localtime instead of 0

bugzilla at busybox.net bugzilla at busybox.net
Thu May 19 13:10:37 UTC 2016


            Bug ID: 8951
           Summary: touch -t 197001010000 will use seconds from localtime
                    instead of 0
           Product: Busybox
           Version: 1.24.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned at busybox.net
          Reporter: ncopa at alpinelinux.org
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

POSIX says about `touch -t [[CC]YY]MMDDhhmm[.SS]`:

> If SS is not given a value, it is assumed to be zero.


Busybox touch does not set it to zero, instead it uses the localtime's seconds.

To reproduce: 

  TZ=UTC strace busybox touch -t 197001010000 /tmp/foo

  utimensat(AT_FDCWD, "/tmp/foo", [{23, 0}, {23, 0}], 0) = 0

note that utimesat(2) is called with the seconds part to 23.

Doing the same with the .ss specified will correctly set the seconds part to 0:

  TZ=UTC strace busybox touch -t 197001010000.00 /tmp/foo

  utimensat(AT_FDCWD, "/tmp/foo", [{0, 0}, {0, 0}], 0) = 0

The reason is that the time_t struct is initialized with localtime instead of

You are receiving this mail because:
You are on the CC list for the bug.

More information about the busybox-cvs mailing list