diff options
author | darin%meer.net <devnull@localhost> | 2004-03-09 23:39:15 +0000 |
---|---|---|
committer | darin%meer.net <devnull@localhost> | 2004-03-09 23:39:15 +0000 |
commit | ed233f042fdd23bed16318fdc60a7d335d9e17e8 (patch) | |
tree | 1972f3b67dd1a742ba41f21847201d7c5576e9b5 | |
parent | e16edcbdde9e6ec8c1ec984e0f1449dceb52afb2 (diff) | |
download | nspr-hg-ed233f042fdd23bed16318fdc60a7d335d9e17e8.tar.gz |
landing patch for bug 236879 "PR_LocalTimeParameters should also check for values that are too small for 32-bit time_t." patch by wtc, r=darin
-rw-r--r-- | pr/src/misc/prtime.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c index 55da78ea..3eae35c7 100644 --- a/pr/src/misc/prtime.c +++ b/pr/src/misc/prtime.c @@ -637,6 +637,7 @@ PR_LocalTimeParameters(const PRExplodedTime *gmt) PRTime secs64; PRInt64 usecPerSec; PRInt64 maxInt32; + PRInt64 minInt32; PRInt32 dayOffset; PRInt32 offset2Jan1970; PRInt32 offsetNew; @@ -682,9 +683,10 @@ PR_LocalTimeParameters(const PRExplodedTime *gmt) secs64 = PR_ImplodeTime(gmt); /* This is still in microseconds */ LL_I2L(usecPerSec, PR_USEC_PER_SEC); LL_DIV(secs64, secs64, usecPerSec); /* Convert to seconds */ - LL_I2L(maxInt32, 0x7fffffff); - if (LL_CMP(secs64, >, maxInt32)) { - /* secs64 is too large for time_t (32-bit integer) */ + LL_I2L(maxInt32, PR_INT32_MAX); + LL_I2L(minInt32, PR_INT32_MIN); + if (LL_CMP(secs64, >, maxInt32) || LL_CMP(secs64, <, minInt32)) { + /* secs64 is too large or too small for time_t (32-bit integer) */ retVal.tp_gmt_offset = offset2Jan1970; retVal.tp_dst_offset = 0; return retVal; |