diff options
author | Vincent Richard <[email protected]> | 2013-02-26 16:51:44 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2013-02-26 16:51:44 +0000 |
commit | 0d6aef849186646462029ce158da0ab4a0b8d91f (patch) | |
tree | ab5f70617344b524e98d9884f90cf5aeabc9b096 | |
parent | Fixed warnings about unused variables. (diff) | |
download | vmime-0d6aef849186646462029ce158da0ab4a0b8d91f.tar.gz vmime-0d6aef849186646462029ce158da0ab4a0b8d91f.zip |
Use secure versions of time/string functions on Windows.
-rw-r--r-- | src/dateTime.cpp | 11 | ||||
-rw-r--r-- | src/platforms/windows/windowsHandler.cpp | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/dateTime.cpp b/src/dateTime.cpp index eaf955c3..58680791 100644 --- a/src/dateTime.cpp +++ b/src/dateTime.cpp @@ -655,17 +655,12 @@ datetime::datetime(const datetime& d) datetime::datetime(const time_t t, const int zone) { -#if defined(_MSC_VER) || defined(__MINGW32__) - // These functions are reentrant in MS C runtime library - struct tm* gtm = gmtime(&t); - struct tm* ltm = localtime(&t); +#if VMIME_HAVE_LOCALTIME_S struct tm tms; - if (gtm) - tms = *gtm; - else if (ltm) - tms = *ltm; + if (!gmtime_r(&tms, &t)) + localtime_r(&tms, &t); #elif VMIME_HAVE_LOCALTIME_R struct tm tms; diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp index b4f605ec..b188af64 100644 --- a/src/platforms/windows/windowsHandler.cpp +++ b/src/platforms/windows/windowsHandler.cpp @@ -224,7 +224,7 @@ const vmime::string windowsHandler::getHostName() const return hostname; if (::strlen(hostname) == 0) - ::strcpy(hostname, "localhost"); + ::strcpy_s(hostname, "localhost"); // Try to get canonical name for the hostname struct addrinfo hints; |