This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1459] New: ctime, asctime produce negative year number
- From: "list+redhat-bugzilla at meyering dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 11 Oct 2005 09:54:58 -0000
- Subject: [Bug libc/1459] New: ctime, asctime produce negative year number
- Reply-to: sourceware-bugzilla at sourceware dot org
When the year number is between INT_MAX-1900 and INT_MAX,
ctime, asctime, ctime_t, asctime_t all format a negative
year number, e.g., -2147483648. They should probably return NULL instead.
Of course, this happens only when time_t is a 64-bit type and int (tm_year)
is a 32-bit type.
The problem is in time/asctime.c (today's CVS).
See the unchecked `+ 1900' below. It can overflow:
if (sprintf (buf, format,
(tp->tm_wday < 0 || tp->tm_wday >= 7 ?
"???" : ab_day_name (tp->tm_wday)),
(tp->tm_mon < 0 || tp->tm_mon >= 12 ?
"???" : ab_month_name (tp->tm_mon)),
tp->tm_mday, tp->tm_hour, tp->tm_min,
tp->tm_sec, 1900 + tp->tm_year) < 0)
--
Summary: ctime, asctime produce negative year number
Product: glibc
Version: 2.3.5
Status: NEW
Severity: minor
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: list+redhat-bugzilla at meyering dot net
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=1459
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.