[Bug 206752] [patch] /bin/date format conversion bug

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Jan 30 00:42:02 UTC 2016


            Bug ID: 206752
           Summary: [patch] /bin/date format conversion bug
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: jrm at ftfl.ca
          Keywords: patch

Created attachment 166294
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=166294&action=edit
svn diff

% date -j -f %Y-%m 2015-02 '+%B %Y'
March 2015

In the code, a tm structure is initially created with the current time.  If
input_fmt and new_date are supplied, then the appropriate values in that tm
structure are overwritten.  The problem is that this can lead to invalid dates
when only a partial input_fmt/new_date are supplied like above.  In the example
above, the tm_mday is left as is (today is the 29th day of the month), but the
tm_mon is overwritten with 01 (February) leading to an invalid date.

The attached patch fixes the above issue by setting the default tm_mday to 1,
when an input_fmt is supplied.

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-bugs mailing list