summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangwan.kwon <sangwan.kwon@samsung.com>2016-12-14 15:35:09 +0900
committersangwan kwon <sangwan.kwon@samsung.com>2016-12-15 01:09:21 -0800
commit81fbac31cc841bd0aaf246f029919633001d4486 (patch)
treee20349a72c146a2eb12b092b8c23a74db04bd5c2
parentd4babe04292c04e226eb03ebd2f96e940c6724c7 (diff)
downloadcert-svc-81fbac31cc841bd0aaf246f029919633001d4486.tar.gz
cert-svc-81fbac31cc841bd0aaf246f029919633001d4486.tar.bz2
cert-svc-81fbac31cc841bd0aaf246f029919633001d4486.zip
[HOTFIX] Fix time conversion bug
[ error ] - Time conversion is not work properly. [ problem ] - mktime() returns the value of type time_t that represents the local time. [ solution ] - Use timegm() for convert tm to time_t as UTC time See, https://linux.die.net/man/3/timegm Change-Id: Ic30fe0054c8f456a2ada13f35f3764e4599c545d Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com> (cherry picked from commit 1ba032d40e6806534a7d0c132af111cea6b06d08)
-rw-r--r--src/vcore/TimeConversion.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/vcore/TimeConversion.cpp b/src/vcore/TimeConversion.cpp
index d183dea..9d56d14 100644
--- a/src/vcore/TimeConversion.cpp
+++ b/src/vcore/TimeConversion.cpp
@@ -341,8 +341,10 @@ int asn1TimeToTimeT(ASN1_TIME *t, time_t *res)
return 0;
char buf[27]; // asctime_r return 26 characters
+ memset(buf, 0, sizeof(buf));
LogDebug("Convert asn1 to tm: " << asctime_r(&tm, buf));
- *res = mktime(&tm);
+ *res = timegm(&tm);
+ LogDebug("Convert tm to time_t: " << *res);
// If time_t occured overflow, set TIME_MAX.
if (*res == -1) {
@@ -350,10 +352,6 @@ int asn1TimeToTimeT(ASN1_TIME *t, time_t *res)
*res = TIME_MAX;
}
- // For Debugging.
- struct tm localTm;
- localtime_r(res, &localTm);
- LogDebug("Result time_t(tm format): " << asctime_r(&localTm, buf));
return 1;
}