Bug 220828 - date(1) segmentation fault. print the date and time of the last modification of filename
Summary: date(1) segmentation fault. print the date and time of the last modification ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-18 13:20 UTC by Vinícius Zavam
Modified: 2017-09-08 12:51 UTC (History)
2 users (show)

See Also:
marius: mfc-stable11+
marius: mfc-stable10+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vinícius Zavam freebsd_committer freebsd_triage 2017-07-18 13:20:44 UTC
HEAD (12.0-CURRENT, r320640) [ino64]

  % uname -mirK ; date ; date -r -67769588800000000
  12.0-CURRENT amd64 GENERIC-NODEBUG 1200037
  Tue Jul 18 14:59:15 CEST 2017
  Segmentation fault (core dumped)

STABLE/11 (11.1-PRERELEASE, r319119)

  % uname -mirK ; date ; date -r -67769588800000000
  11.1-PRERELEASE amd64 GENERIC 1100513
  Tue Jul 18 14:49:17 CEST 2017
  Segmentation fault (core dumped) 

STABLE/11 (11.0-STABLE, r315133)

  % uname -mirK ; date ; date -r -67769588800000000
  11.0-STABLE amd64 GENERIC 1100509
  Tue Jul 18 14:48:47 CEST 2017
  Segmentation fault (core dumped)

  % env TZ= date -r -67769588800000000
  Segmentation fault (core dumped)

  % date -r date.core 
  Tue Jul 18 15:05:26 CEST 2017

  % ident /bin/date
  /bin/date:
     $FreeBSD: stable/11/lib/csu/amd64/crt1.c 292000 2015-12-08 19:32:58Z emaste $
     $FreeBSD: stable/11/lib/csu/common/crtbrand.c 232832 2012-03-11 20:04:09Z kib $
     $FreeBSD: stable/11/lib/csu/common/ignore_init.c 245133 2013-01-07 17:58:27Z kib $
     $FreeBSD: stable/11/lib/csu/amd64/crti.S 217105 2011-01-07 16:07:51Z kib $
     $FreeBSD: stable/11/bin/date/date.c 282608 2015-05-07 20:54:38Z delphij $
     $FreeBSD: stable/11/bin/date/netdate.c 244538 2012-12-21 15:54:13Z kevlo $
     $FreeBSD: stable/11/bin/date/vary.c 133381 2004-08-09 13:43:39Z yar $
     $FreeBSD: stable/11/lib/csu/amd64/crtn.S 217105 2011-01-07 16:07:51Z kib $

STABLE/10 (10.3-STABLE, 1003501)

  % uname -mirK ; date ; date -r -67769588800000000
  10.3-STABLE amd64 GENERIC 1003501
  Tue Jul 18 15:13:29 CEST 2017
  Sun Jan  0 00:00:00 LMT 1900

  % ident /bin/date
  /bin/date:
     $FreeBSD: stable/10/lib/csu/amd64/crt1.c 245133 2013-01-07 17:58:27Z kib $
     $FreeBSD: stable/10/lib/csu/common/crtbrand.c 232832 2012-03-11 20:04:09Z kib $
     $FreeBSD: stable/10/lib/csu/common/ignore_init.c 245133 2013-01-07 17:58:27Z kib $
     $FreeBSD: stable/10/lib/csu/amd64/crti.S 217105 2011-01-07 16:07:51Z kib $
     $FreeBSD: stable/10/bin/date/date.c 283258 2015-05-21 18:59:11Z delphij $
     $FreeBSD: stable/10/bin/date/netdate.c 244538 2012-12-21 15:54:13Z kevlo $
     $FreeBSD: stable/10/bin/date/vary.c 133381 2004-08-09 13:43:39Z yar $
     $FreeBSD: stable/10/lib/csu/amd64/crtn.S 217105 2011-01-07 16:07:51Z kib $
Comment 1 Ed Maste freebsd_committer freebsd_triage 2017-07-19 18:14:09 UTC
Proposed fix in https://reviews.freebsd.org/D11660
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-07-20 15:29:31 UTC
A commit references this bug:

Author: emaste
Date: Thu Jul 20 15:28:48 UTC 2017
New revision: 321293
URL: https://svnweb.freebsd.org/changeset/base/321293

Log:
  date: avoid crash on invalid time

  localtime(3) returns NULL when passed an invalid time_t but date(1)
  previously did not handle it. Exit with an error in that case.

  PR:		220828
  Reported by:	Vin?cius Zavam
  Reviewed by:	cem, kevans
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D11660

Changes:
  head/bin/date/date.c
Comment 3 Vinícius Zavam freebsd_committer freebsd_triage 2017-07-21 09:42:55 UTC
(In reply to commit-hook from comment #2)

I confirm it works.

root@freebsd-12-0:/usr/src/bin/date # svnlite info
Path: .
Working Copy Root Path: /usr/src
URL: https://svn.freebsd.org/base/head/bin/date
Relative URL: ^/head/bin/date
Repository Root: https://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 321326
Node Kind: directory
Schedule: normal
Last Changed Author: emaste
Last Changed Rev: 321293
Last Changed Date: 2017-07-20 15:28:48 +0000 (Thu, 20 Jul 2017)

root@freebsd-12-0:/usr/src/bin/date # make -s all install clean
===> tests (all)
===> tests (install)
===> tests (clean)

root@freebsd-12-0:/usr/src/bin/date # rehash 

root@freebsd-12-0:/usr/src/bin/date # uname -mirK ; date ; date -r -67769588800000000
12.0-CURRENT amd64 GENERIC 1200038
Fri Jul 21 09:40:04 UTC 2017
date: invalid time
Comment 4 Ed Maste freebsd_committer freebsd_triage 2017-07-21 15:28:16 UTC
Thank you for the confirmation.
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-08-31 02:38:47 UTC
A commit references this bug:

Author: emaste
Date: Thu Aug 31 02:37:45 UTC 2017
New revision: 323044
URL: https://svnweb.freebsd.org/changeset/base/323044

Log:
  MFC r321293: date: avoid crash on invalid time

  localtime(3) returns NULL when passed an invalid time_t but date(1)
  previously did not handle it. Exit with an error in that case.

  PR:		220828
  Submitted by:	Vin?cius Zavam

Changes:
_U  stable/11/
  stable/11/bin/date/date.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2017-09-07 23:30:01 UTC
A commit references this bug:

Author: marius
Date: Thu Sep  7 23:28:36 UTC 2017
New revision: 323291
URL: https://svnweb.freebsd.org/changeset/base/323291

Log:
  MFC: r321293

  date: avoid crash on invalid time

  PR:		220828
  Approved by:	re (kib)

Changes:
_U  stable/10/
  stable/10/bin/date/date.c
Comment 7 Ed Maste freebsd_committer freebsd_triage 2017-09-08 12:51:41 UTC
Marius thanks for handling the MFC to stable/10.