Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNERGY-956 - Resolve code scanning issues #7006

Merged
merged 7 commits into from
May 26, 2021
Merged
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v1.14.1-snapshot
===========
Bug fixes:
- #7016 Fix script that generates version number
- #7006 Resolve code scanning issues

Enhancements:

Expand Down
10 changes: 7 additions & 3 deletions src/lib/base/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ Log::print(const char* file, int line, const char* fmt, ...)
// do not prefix time and file for kPRINT (CLOG_PRINT)
if (priority != kPRINT) {

struct tm *tm;
struct tm tm;
static const int timestamp_size = 50;
char timestamp[timestamp_size];
time_t t;
time(&t);
tm = localtime(&t);
snprintf(timestamp, timestamp_size, "%04i-%02i-%02iT%02i:%02i:%02i", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
#if WINAPI_MSWINDOWS
localtime_s(&tm, &t);
#else
localtime_r(&t, &tm);
#endif
snprintf(timestamp, timestamp_size, "%04i-%02i-%02iT%02i:%02i:%02i", tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);

// square brackets, spaces, comma and null terminator take about 10
int size = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/InputFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ InputFilter::KeyboardBroadcastAction::format() const
}
else {
return synergy::string::sprintf("%s(%s,%.*s)", s_name, s_mode[m_mode],
m_screens.size() - 2,
static_cast<int>(m_screens.size() >= 2 ? m_screens.size() - 2 : 0),
m_screens.c_str() + 1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/unittests/synergy/ProtocolUtilTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MATCHER_P(EqVoidPointeeInt32, expected, "")
MATCHER_P(EqVoidVectorInt1byte, expected, "")
{
bool Result = true;
const UInt8* Actual = (static_cast<const UInt8*>(arg)) + sizeof (UInt32);
const UInt8* Actual = (static_cast<const UInt8*>(arg)) + 4;
const size_t Size = *(Actual - 1);

if (Size == expected.size()){
Expand All @@ -77,7 +77,7 @@ MATCHER_P(EqVoidVectorInt1byte, expected, "")
MATCHER_P(EqVoidVectorInt2bytes, expected, "")
{
bool Result = true;
const UInt16* Actual = (static_cast<const UInt16*>(arg)) + sizeof (UInt16);
const UInt16* Actual = (static_cast<const UInt16*>(arg)) + 2;
const size_t Size = *(Actual - 1) >> 8;

if (Size == expected.size()){
Expand Down