Fix GCC 8 memset warning and set -Werror only for debug builds, resolves #1558

This commit is contained in:
Janek Bevendorff 2018-03-03 14:19:51 +01:00
parent 02b923b0e5
commit d3a80513a7
2 changed files with 10 additions and 2 deletions

View File

@ -157,11 +157,15 @@ if(WITH_APP_BUNDLE)
endif()
add_gcc_compiler_flags("-fno-common")
add_gcc_compiler_flags("-Wall -Werror -Wextra -Wundef -Wpointer-arith -Wno-long-long")
add_gcc_compiler_flags("-Wall -Wextra -Wundef -Wpointer-arith -Wno-long-long")
add_gcc_compiler_flags("-Wformat=2 -Wmissing-format-attribute")
add_gcc_compiler_flags("-fvisibility=hidden")
add_gcc_compiler_cxxflags("-fvisibility-inlines-hidden")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_gcc_compiler_flags("-Werror")
endif()
if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.999) OR CMAKE_COMPILER_IS_CLANGXX)
add_gcc_compiler_flags("-fstack-protector-strong")
else()

View File

@ -140,7 +140,11 @@ void Server::generatePassword(const Request &r, Response *protocolResp)
protocolResp->setVerifier(key);
protocolResp->setEntries(QList<Entry>() << Entry("generate-password", bits, password, "generate-password"));
memset(password.data(), 0, password.length());
int size = password.capacity();
volatile auto* mem = reinterpret_cast<volatile ushort*>(password.data());
while (size--) {
*mem++ = 0;
}
}
void Server::handleRequest(const QByteArray& data, QHttpResponse* response)