Set time_t max value 09/67309/2
authorsangwan.kwon <sangwan.kwon@samsung.com>
Tue, 26 Apr 2016 08:03:08 +0000 (17:03 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Wed, 27 Apr 2016 01:30:21 +0000 (10:30 +0900)
[probelm] After 2038 years, time_t cause overflow in 32bit arch
[error]   Because time_t is 4byte in 32bit arch
[solve]   If overflow occured, set max value

Change-Id: I3f1d2144f4a2a96092e7b6a8710c0e7447e2975f

vcore/vcore/TimeConversion.cpp

index a796ce7..67c258b 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+/*
+ * @file        TimeConversion.cpp
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+ * @version     0.1
+ * @brief
+ */
 #include <vcore/TimeConversion.h>
 
 #include <cstring>
+#include <climits>
+
+#define TIME_MAX LONG_MAX // time_t max value in arch 32bit
 
 namespace {
 
@@ -276,8 +286,12 @@ int asn1TimeToTimeT(ASN1_TIME *t, time_t *res)
         return 0;
 
     *res = mktime(&tm);
+
+    // If time_t occured overflow, set TIME_MAX.
+    if(*res == -1)
+        *res = TIME_MAX;
+
     return 1;
 }
 
 } // namespace ValidationCore
-