summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2011-02-02 18:51:35 +0200
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2011-02-02 18:51:35 +0200
commit59f68983ffee45616a8ec255b5f13535236dd0ea (patch)
tree15a94e6095dd7f48a3a40e2c6d798d5f7b728b0e /sql-common
parent4eb7054598196f474bfef50318a483c20bc29b87 (diff)
downloadmariadb-git-59f68983ffee45616a8ec255b5f13535236dd0ea.tar.gz
Fixes for Bug #55755 and Bug #52315 part 2
Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that is safe to use with datetime functions and store in TIMESTAMP columns. * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added overflow checking before converting to time_t. * Using a correct localized error message in this case instead of the generic error. * Added a test suite. * fixed the checks so that they check for unsigned time_t as well. Used the checks consistently across the source code. * fixed the original test case to expect the new error code.
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/my_time.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index ed1279f7afb..07cb8b25c46 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -985,7 +985,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
with unsigned time_t tmp+= shift*86400L might result in a number,
larger then TIMESTAMP_MAX_VALUE, so another check will work.
*/
- if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
+ if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tmp))
tmp= 0;
return (my_time_t) tmp;