Commit 725c7cca authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

some fixes after github codeql-analysis

parent 248791e2
...@@ -140,7 +140,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query, ...@@ -140,7 +140,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
} }
// Фомирование ответа: // Фомирование ответа:
ModbusData num = 0; // добавленное количество данных size_t num = 0; // добавленное количество данных
size_t bcnt = numBytes(query.count); size_t bcnt = numBytes(query.count);
for( ; num < bcnt; num++ ) for( ; num < bcnt; num++ )
......
...@@ -38,7 +38,7 @@ TEST_CASE("[REST API: conf]", "[restapi][configure]") ...@@ -38,7 +38,7 @@ TEST_CASE("[REST API: conf]", "[restapi][configure]")
{ {
init_test(); init_test();
std::string s = shm->apiRequest("/configure/get?2,Input5_S&params=iotype"); std::string s = shm->apiRequest("/configure/get?2,Input5_S&params=iotype");
Poco::JSON::Parser parser; Poco::JSON::Parser parser;
auto result = parser.parse(s); auto result = parser.parse(s);
......
...@@ -3167,14 +3167,15 @@ namespace uniset ...@@ -3167,14 +3167,15 @@ namespace uniset
func = fnSetDateTime; func = fnSetDateTime;
time_t tm = time(0); time_t tm = time(0);
struct tm* tms = localtime(&tm); std::tm tms;
hour = tms->tm_hour; gmtime_r(&tm, &tms);
min = tms->tm_min; hour = tms.tm_hour;
sec = tms->tm_sec; min = tms.tm_min;
day = tms->tm_mday; sec = tms.tm_sec;
mon = tms->tm_mon + 1; day = tms.tm_mday;
year = tms->tm_year; mon = tms.tm_mon + 1;
century = ( tms->tm_year + 1900 >= 2000 ) ? 20 : 19; year = tms.tm_year;
century = ( tms.tm_year + 1900 >= 2000 ) ? 20 : 19;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
SetDateTimeRetMessage::SetDateTimeRetMessage( const SetDateTimeMessage& query ) SetDateTimeRetMessage::SetDateTimeRetMessage( const SetDateTimeMessage& query )
......
...@@ -503,21 +503,23 @@ bool uniset::check_filter( UniXML::iterator& it, const std::string& f_prop, cons ...@@ -503,21 +503,23 @@ bool uniset::check_filter( UniXML::iterator& it, const std::string& f_prop, cons
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
string uniset::timeToString(time_t tm, const std::string& brk ) noexcept string uniset::timeToString(time_t tm, const std::string& brk ) noexcept
{ {
struct tm* tms = localtime(&tm); std::tm tms;
gmtime_r(&tm, &tms);
ostringstream time; ostringstream time;
time << std::setw(2) << std::setfill('0') << tms->tm_hour << brk; time << std::setw(2) << std::setfill('0') << tms.tm_hour << brk;
time << std::setw(2) << std::setfill('0') << tms->tm_min << brk; time << std::setw(2) << std::setfill('0') << tms.tm_min << brk;
time << std::setw(2) << std::setfill('0') << tms->tm_sec; time << std::setw(2) << std::setfill('0') << tms.tm_sec;
return time.str(); return time.str();
} }
string uniset::dateToString(time_t tm, const std::string& brk ) noexcept string uniset::dateToString(time_t tm, const std::string& brk ) noexcept
{ {
struct tm* tms = localtime(&tm); std::tm tms;
gmtime_r(&tm, &tms);
ostringstream date; ostringstream date;
date << std::setw(4) << std::setfill('0') << tms->tm_year + 1900 << brk; date << std::setw(4) << std::setfill('0') << tms.tm_year + 1900 << brk;
date << std::setw(2) << std::setfill('0') << tms->tm_mon + 1 << brk; date << std::setw(2) << std::setfill('0') << tms.tm_mon + 1 << brk;
date << std::setw(2) << std::setfill('0') << tms->tm_mday; date << std::setw(2) << std::setfill('0') << tms.tm_mday;
return date.str(); return date.str();
} }
......
...@@ -210,7 +210,8 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept ...@@ -210,7 +210,8 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept
uniset::ios_fmt_restorer ifs(*this); uniset::ios_fmt_restorer ifs(*this);
std::time_t tv = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::time_t tv = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm tms = *std::localtime(&tv); std::tm tms;
gmtime_r(&tv, &tms);
#if __GNUC__ >= 5 #if __GNUC__ >= 5
std::ostringstream fmt; std::ostringstream fmt;
...@@ -233,7 +234,8 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept ...@@ -233,7 +234,8 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept
uniset::ios_fmt_restorer ifs(*this); uniset::ios_fmt_restorer ifs(*this);
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0); timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec); std::tm tms;
gmtime_r(&tv.tv_sec, &tms);
#if __GNUC__ >= 5 #if __GNUC__ >= 5
std::ostringstream fmt; std::ostringstream fmt;
...@@ -263,7 +265,8 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept ...@@ -263,7 +265,8 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept
uniset::ios_fmt_restorer ifs(*this); uniset::ios_fmt_restorer ifs(*this);
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0); timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec); std::tm tms;
gmtime_r(&tv.tv_sec, &tms);
#if __GNUC__ >= 5 #if __GNUC__ >= 5
*this << std::put_time(&tms, "%Od/%Om/%Y %OH:%OM:%OS"); *this << std::put_time(&tms, "%Od/%Om/%Y %OH:%OM:%OS");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment