[Groonga-mysql-commit] mroonga/mroonga [master] Add time overflow check for 32bit environment

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Oct 24 22:23:20 JST 2012


Kouhei Sutou	2012-10-24 22:23:20 +0900 (Wed, 24 Oct 2012)

  New Revision: f5dab854220b431bc2797ed64be9a7364a075d9b
  https://github.com/mroonga/mroonga/commit/f5dab854220b431bc2797ed64be9a7364a075d9b

  Log:
    Add time overflow check for 32bit environment

  Modified files:
    ha_mroonga.cpp

  Modified: ha_mroonga.cpp (+3 -1)
===================================================================
--- ha_mroonga.cpp    2012-10-24 19:10:54 +0900 (aefb05f)
+++ ha_mroonga.cpp    2012-10-24 22:23:20 +0900 (3d6b614)
@@ -1507,7 +1507,9 @@ static long long int mrn_tm_to_grn_time(struct tm *time, int usec)
   MRN_DBUG_ENTER_FUNCTION();
   long long int grn_time;
   long long int sec = mktime(time);
-  if (sec == -1) {
+  bool failed = (sec == -1);
+  bool overflowed = (time.tm_year >= 0 && sec < 0);
+  if (failed || overflowed) {
     grn_time = 0;
   } else {
     grn_time = GRN_TIME_PACK(sec + mrn_utc_diff_in_seconds, usec);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index