8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 20:03:03 +01:00

Fixed server crash when too big/small system year is set up.

This commit is contained in:
dimitr 2004-03-21 09:47:39 +00:00
parent 5b7f1792a6
commit 869b69bed4
3 changed files with 52 additions and 23 deletions

View File

@ -1387,18 +1387,27 @@ void CVT_move(const dsc* from, dsc* to, FPTR_ERROR err)
tdbb->tdbb_request)
{
if (tdbb->tdbb_request->req_timestamp)
{
clock = tdbb->tdbb_request->req_timestamp;
else {
/* All requests should have a timestamp */
fb_assert(FALSE);
clock = time(0);
}
else
{
// all requests should have a timestamp
fb_assert(false);
clock = time(NULL);
}
}
else
clock = time(0);
const tm times = *localtime(&clock);
{
clock = time(NULL);
}
const tm* times = localtime(&clock);
if (!times)
{
(*err)(isc_date_range_exceeded, 0);
}
GDS_TIMESTAMP enc_times;
isc_encode_timestamp(&times, &enc_times);
isc_encode_timestamp(times, &enc_times);
((GDS_TIMESTAMP*) (to->dsc_address))->timestamp_date =
enc_times.timestamp_date;
}
@ -2419,8 +2428,7 @@ static void string_to_datetime(
USHORT position_day = 2;
bool have_english_month = false;
bool dot_separator_seen = false;
time_t clock;
tm times, times2;
tm times, times2, *ptimes;
TEXT buffer[100]; /* arbitrarily large */
const char* string;
@ -2508,8 +2516,13 @@ static void string_to_datetime(
/* fetch the current time */
clock = time(0);
times2 = *localtime(&clock);
const time_t clock = time(NULL);
ptimes = localtime(&clock);
if (!ptimes)
{
(err)(isc_date_range_exceeded, 0);
}
times2 = *ptimes;
if (strcmp(temp, NOW) == 0) {
isc_encode_timestamp(&times2, date);
@ -2639,19 +2652,23 @@ static void string_to_datetime(
times.tm_mon = components[position_month];
times.tm_mday = components[position_day];
const time_t clock = time(NULL);
ptimes = localtime(&clock);
if (!ptimes)
{
(err)(isc_date_range_exceeded, 0);
}
times2 = *ptimes;
/* Handle defaulting of year */
if (description[position_year] == 0) {
clock = time(0);
times2 = *localtime(&clock);
times.tm_year = times2.tm_year + 1900;
}
/* Handle conversion of 2-digit years */
else if (description[position_year] <= 2) {
clock = time(0);
times2 = *localtime(&clock);
if (times.tm_year < (times2.tm_year - 50) % 100)
times.tm_year += 2000;
else

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: evl.cpp,v 1.70 2004-03-20 14:57:29 alexpeshkoff Exp $
* $Id: evl.cpp,v 1.71 2004-03-21 09:47:39 dimitr Exp $
*/
/*
@ -901,12 +901,20 @@ dsc* EVL_expr(thread_db* tdbb, jrd_nod* node)
// fetch the current clock in order to keep running
if (request->req_timestamp)
{
clock = request->req_timestamp;
else {
fb_assert(FALSE);
clock = time(0);
}
tm times = *localtime(&clock);
else
{
fb_assert(false);
clock = time(NULL);
}
const tm* ptimes = localtime(&clock);
if (!ptimes)
{
ERR_post(isc_date_range_exceeded, 0);
}
tm times = *ptimes;
memset(&impure->vlu_desc, 0, sizeof(impure->vlu_desc));
impure->vlu_desc.dsc_address =

View File

@ -36,7 +36,7 @@
#include "../jrd/err_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/mov_proto.h"
#include "gen/iberror.h"
int MOV_compare(const dsc* arg1, const dsc* arg2)
@ -586,7 +586,11 @@ void MOV_time_stamp(GDS_TIMESTAMP* date)
*
**************************************/
const time_t clock = time(NULL);
const tm times = *localtime(&clock);
isc_encode_timestamp(&times, date);
const tm* times = localtime(&clock);
if (!times)
{
ERR_post(isc_date_range_exceeded, 0);
}
isc_encode_timestamp(times, date);
}