Rename 2038 epoch check to something more accurate & less alarming than 'TimeBombExploded' (sheesh), and only bother with it if time_t is 32 bits.

This commit is contained in:
Brian Cox 2017-07-31 18:49:36 -07:00
parent 24dba1b374
commit d8e323e186
11 changed files with 73 additions and 56 deletions

View File

@ -174,6 +174,9 @@
/* The size of `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* The size of `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T
/* Don't use gethostbyname() on Solaris */
#undef SOLARIS_NO_GETHOSTBYNAME

33
configure vendored
View File

@ -6058,6 +6058,39 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5
$as_echo_n "checking size of time_t... " >&6; }
if ${ac_cv_sizeof_time_t+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "$ac_includes_default"; then :
else
if test "$ac_cv_type_time_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (time_t)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_time_t=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5
$as_echo "$ac_cv_sizeof_time_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_TIME_T $ac_cv_sizeof_time_t
_ACEOF
$as_echo "#define USES_1S_COMPLEMENT 0" >>confdefs.h

View File

@ -99,6 +99,7 @@ AC_C_BIGENDIAN
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(time_t)
dnl All platforms we support use 2's complement, are byte aligned, etc...
AC_DEFINE(USES_1S_COMPLEMENT, 0, [Uses one's complement])

View File

@ -9,25 +9,25 @@ libcore_a_SOURCES = \
archive.cpp charutil.cpp \
cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \
corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
displayutil.cpp epoch.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp \
wchar16.cpp
libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
core.h coreerrors.h corestrings.h crc32.h debug.h displayencoder.h \
displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
displayutil.h epoch.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \
fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \
sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \
tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
tchar.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \
usernotify.h usernotifystdout.h wchar16.h

View File

@ -113,8 +113,8 @@ am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \
archive.$(OBJEXT) charutil.$(OBJEXT) cmdlineparser.$(OBJEXT) \
codeconvert.$(OBJEXT) core.$(OBJEXT) coreerrors.$(OBJEXT) \
corestrings.$(OBJEXT) crc32.$(OBJEXT) debug.$(OBJEXT) \
displayencoder.$(OBJEXT) displayutil.$(OBJEXT) error.$(OBJEXT) \
errorbucketimpl.$(OBJEXT) errortable.$(OBJEXT) \
displayencoder.$(OBJEXT) displayutil.$(OBJEXT) epoch.$(OBJEXT) \
error.$(OBJEXT) errorbucketimpl.$(OBJEXT) errortable.$(OBJEXT) \
errorutil.$(OBJEXT) fileerror.$(OBJEXT) fileheader.$(OBJEXT) \
fsservices.$(OBJEXT) growheap.$(OBJEXT) hashtable.$(OBJEXT) \
haval.$(OBJEXT) msystem.$(OBJEXT) ntmbs.$(OBJEXT) \
@ -122,9 +122,9 @@ am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \
serializer.$(OBJEXT) serializerimpl.$(OBJEXT) \
serializerutil.$(OBJEXT) serstring.$(OBJEXT) \
srefcountobj.$(OBJEXT) srefcounttbl.$(OBJEXT) \
stdcore.$(OBJEXT) stringutil.$(OBJEXT) timebomb.$(OBJEXT) \
timeconvert.$(OBJEXT) tw_signal.$(OBJEXT) twlimits.$(OBJEXT) \
twlocale.$(OBJEXT) unixexcept.$(OBJEXT) usernotify.$(OBJEXT) \
stdcore.$(OBJEXT) stringutil.$(OBJEXT) timeconvert.$(OBJEXT) \
tw_signal.$(OBJEXT) twlimits.$(OBJEXT) twlocale.$(OBJEXT) \
unixexcept.$(OBJEXT) usernotify.$(OBJEXT) \
usernotifystdout.$(OBJEXT) wchar16.$(OBJEXT)
libcore_a_OBJECTS = $(am_libcore_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
@ -334,25 +334,25 @@ libcore_a_SOURCES = \
archive.cpp charutil.cpp \
cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \
corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
displayutil.cpp epoch.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp \
wchar16.cpp
libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
core.h coreerrors.h corestrings.h crc32.h debug.h displayencoder.h \
displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
displayutil.h epoch.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \
fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \
sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \
tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
tchar.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \
usernotify.h usernotifystdout.h wchar16.h

View File

@ -30,44 +30,21 @@
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// timebomb.h
// epoch.h
#include "stdcore.h"
#include "timebomb.h"
#include "epoch.h"
#include <time.h>
#include <iostream>
#include "timeconvert.h"
#include "corestrings.h"
///////////////////////////////////////////////////////////////////////////////
// TimeBombExploded() -- Call from main(). Prints out timebomb message and
// returns true if main() should exit.
//
bool TimeBombExploded()
bool CheckEpoch()
{
#if SIZEOF_TIME_T == 4
struct tm time_struct;
/*
memset(&time_struct, 0, sizeof(time_struct));
time_struct.tm_mday = 25;
time_struct.tm_mon = 0;
time_struct.tm_year = 99;
int64 begin = cTimeUtil::DateToTime( &time_struct );
memset(&time_struct, 0, sizeof(time_struct));
time_struct.tm_mday = 1;
time_struct.tm_mon = 4;
time_struct.tm_year = 99;
int64 end = cTimeUtil::DateToTime( &time_struct );
int64 now = time(0);
if (now < begin || now > end)
{
std::cerr << "This beta version of Tripwire(R) has expired.\n";
return true;
}
*/
// Many functions will fail as we approach the end of the epoch
// Rather than crashing, we will exit with a nice message
memset(&time_struct, 0, sizeof(time_struct));
@ -83,5 +60,8 @@ bool TimeBombExploded()
}
return false;
#else
return false;
#endif
}

View File

@ -30,16 +30,16 @@
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// timebomb.h
// epoch.h
#ifndef __TIMEBOMB_H
#define __TIMEBOMB_H
#ifndef __EPOCH_H
#define __EPOCH_H
///////////////////////////////////////////////////////////////////////////////
// TimeBombExploded() -- Call from main(). Prints out timebomb message and
// CheckEpoch() -- Call from main(). Prints out timebomb message and
// returns true if main() should exit.
//
bool TimeBombExploded();
bool CheckEpoch();
#endif

View File

@ -43,7 +43,7 @@
#include "core/cmdlineparser.h"
#include "core/errorbucketimpl.h"
#include "core/usernotifystdout.h"
#include "core/timebomb.h"
#include "core/epoch.h"
#include "fs/fsstrings.h"
#include "tw/twstrings.h"
#include "tw/twutil.h" // for cTWUtil::PrintErrorMsg
@ -104,7 +104,7 @@ int __cdecl _tmain(int argc, const TCHAR** argv)
{
int ret = 0;
if (TimeBombExploded())
if (CheckEpoch())
return 1;
try

View File

@ -43,7 +43,7 @@
#include "tw/configfile.h"
#include "core/errorbucketimpl.h"
#include "core/usernotifystdout.h"
#include "core/timebomb.h"
#include "core/epoch.h"
#include <memory> // for auto_ptr / unique_ptr
#include <iostream>
#include <exception>
@ -107,7 +107,7 @@ void tw_unexpected_handler()
int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
{
if (TimeBombExploded())
if (CheckEpoch())
return 8;
int ret = 0;

View File

@ -42,7 +42,7 @@
#include "tw/twutil.h"
#include "tw/twstrings.h"
#include "twadminstrings.h"
#include "core/timebomb.h"
#include "core/epoch.h"
#include "core/errorbucketimpl.h"
#include "core/archive.h"
@ -73,7 +73,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
int ret = 0;
if (TimeBombExploded())
if (CheckEpoch())
return 1;
cTWInit twInit;

View File

@ -42,7 +42,7 @@
#include "core/cmdlineparser.h"
#include "core/errorbucketimpl.h"
#include "core/usernotifystdout.h"
#include "core/timebomb.h"
#include "core/epoch.h"
#include "core/debug.h"
@ -81,7 +81,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ] )
int ret = 0;
if (TimeBombExploded())
if (CheckEpoch())
return 1;
cTWInit twInit;