View Issue Details

IDProjectCategoryView StatusLast Update
0000587LDMud 3.3Portabilitypublic2018-01-29 21:57
Reporterzesstra Assigned Tozesstra  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSMacOS XOS Version10.5.x
Product Version3.3.718 
Target Version3.3.719Fixed in Version3.3.719 
Summary0000587: Possible crash in strftime(), gmtime() and localtime() on 64 bit platforms with timestamp values > 2^55
DescriptionThe values for the 'time' argument of strftime, gmtime() and localtime() are limited to __INT_MAX__.
Unfortunately, at least several libc (libc in MacOS X 10.5.x, glibc), return a NULL with large values of time_t (between 2^55 and 2^56), when the year does not fit into an int. (On my MacOS, this is undocumented. *grrr*)

The driver never checks the return value of gmtime() and localtime() (probably because Lars developed on MacOS as well and read the faulty manpage), which leads to the segfault.
Steps To Reproducegmtime(__INT_MAX__);
localtime(__INT_MAX__);
strftime(__INT_MAX__);
TagsNo tags attached.

Activities

zesstra

2009-01-16 06:00

administrator   ~0000901

This issue is a little bit tricky...
So far I found no guaranteed upper limit for time_t (except of 2^32-1 I guess) which any of the time manipulation functions accept... Does anybody knows more?

We could limit the input to time strftime() (or maybe time functions in general) to some hundred years, but that may not be long enough for Muds with an own (accelerated) time frame.

zesstra

2009-02-13 06:14

administrator   ~0000948

I added a test for this to begin with.
Would be nice to check on different systems if they are affected / have a buggy strftime() in their libc.

zesstra

2009-02-13 08:05

administrator   ~0000949

Menaures (Gentoo 64, x86_64-pc-linux-gnu-4.3.3) and Fireddl (ELF 64-bit LSB executable, AMD x86-64, Debian etch, glibc-2.3.6) report the same behaviour: 2^55 is still ok, 2^56 crashes.

zesstra

2009-02-13 12:14

administrator   ~0000951

OK, for the record: the crash in the libc occurs in gmtime()/localtime(), not strftime(). Should have noted it from the beginning, but changes little besides that our efuns gmtime() and localtime() are now affected as well. ;-)

zesstra

2009-02-15 08:57

administrator   ~0000953

Ok. 3rd try and this time I got the explanation right, I hope. ;-) It is also much easier to fix properly. *g*

zesstra

2009-02-15 09:29

administrator   ~0000954

Should be fixed by r2519, which also adds additional tests for the other affected efuns to the testsuite.

Issue History

Date Modified Username Field Change
2008-12-14 17:17 zesstra New Issue
2008-12-14 17:17 zesstra Status new => assigned
2008-12-14 17:17 zesstra Assigned To => zesstra
2009-01-08 05:05 zesstra Target Version => 3.3.719
2009-01-16 06:00 zesstra Note Added: 0000901
2009-02-13 06:14 zesstra Note Added: 0000948
2009-02-13 08:05 zesstra Note Added: 0000949
2009-02-13 12:14 zesstra Note Added: 0000951
2009-02-13 12:14 zesstra Severity minor => crash
2009-02-13 12:14 zesstra Product Version => 3.3.718
2009-02-13 12:14 zesstra Summary Possible crash in strftime() on 64 bit platforms with timestamp values > 2^55 => Possible crash in strftime(), gmtime() and localtime() on 64 bit platforms with timestamp values > 2^55
2009-02-13 12:14 zesstra Description Updated
2009-02-13 12:14 zesstra Steps to Reproduce Updated
2009-02-15 08:57 zesstra Note Added: 0000953
2009-02-15 08:57 zesstra Description Updated
2009-02-15 09:29 zesstra Note Added: 0000954
2009-02-15 09:29 zesstra Status assigned => resolved
2009-02-15 09:29 zesstra Fixed in Version => 3.3.719
2009-02-15 09:29 zesstra Resolution open => fixed
2010-11-16 09:42 zesstra Source_changeset_attached => ldmud.git master cd349454
2010-11-16 09:42 zesstra Source_changeset_attached => ldmud.git master ff70fb17
2018-01-29 18:59 zesstra Source_changeset_attached => ldmud.git master cd349454
2018-01-29 18:59 zesstra Source_changeset_attached => ldmud.git master ff70fb17
2018-01-29 21:57 zesstra Source_changeset_attached => ldmud.git master cd349454
2018-01-29 21:57 zesstra Source_changeset_attached => ldmud.git master ff70fb17