Skip to content

Commit

Permalink
fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gcontini committed Mar 15, 2020
1 parent ae9cc0f commit a7d354a
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
14 changes: 5 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if(UNIX) #this is true for all the linux systems but not for cross compiling "li
endif()
endif(THREADS_HAVE_PTHREAD_ARG)

#Zlib required when openssl version < 1.0.1f (centos 7)
#Zlib required with old openssl version < 1.0.1f in centos 7
IF(OPENSSL_VERSION VERSION_LESS_EQUAL 1.0.2)
SET ( ZLIB_USE_STATIC_LIBS ON )
find_package(ZLIB REQUIRED)
Expand Down Expand Up @@ -90,16 +90,12 @@ else(UNIX)
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
SET(Boost_USE_STATIC_RUNTIME ON)
endif(${STATIC_RUNTIME})

add_definitions("/D _CRT_SECURE_NO_WARNINGS")
list(APPEND EXTERNAL_LIBS "bcrypt" "crypt32" "ws2_32" "iphlpapi")
else(MSVC)
if(MINGW)
list(APPEND EXTERNAL_LIBS "-lcrypt32 -lbcrypt -lws2_32 -liphlpapi")
SET(CMAKE_EXE_LINKER_FLAGS "-static")
#super ugly bug when cross compiling in cmake 3.16
#IF(CMAKE_CROSSCOMPILING)
# link_directories(BEFORE /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32)
#ENDIF()
if(MINGW)
list(APPEND EXTERNAL_LIBS "-lbcrypt" "-lcrypt32" "-lws2_32" "-liphlpapi")
SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++")
endif(MINGW)
endif(MSVC)
set(main_lib_dest "${PROJECT_NAME}")
Expand Down
3 changes: 2 additions & 1 deletion doc/snippets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ if not exist "C:/local/boost/libs" (

linux cross compile for windows openssl

./Configure no-zlib no-shared --prefix=$PWD/dist-win-64 --cross-compile-prefix=x86_64-w64-mingw32- mingw64
./Configure no-zlib no-shared --prefix=$PWD/dist-win-64 --cross-compile-prefix=x86_64-w64-mingw32- mingw64
/usr/local/bin/cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/../../boost_1_69_0/dist-win-x64/ -DOPENSSL_ROOT_DIR=$PWD/../../openssl-OpenSSL_1_1_1d/dist-win-64/ -DBoost_ARCHITECTURE="-x64" -DCMAKE_CXX_COMPILER_ARCHITECTURE_ID="x64" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_VERBOSE_MAKEFILE=ON -DLOGS_DISABLED=ON ..
9 changes: 5 additions & 4 deletions src/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
using namespace std;
using namespace license::os;

const map<int, string> stringByStrategyId = {{STRATEGY_DEFAULT, "DEFAULT"}, {STRATEGY_ETHERNET, "MAC"},
{STRATEGY_IP_ADDRESS, "IP"}, {STRATEGY_DISK_NUM, "Disk1"},
{STRATEGY_DISK_LABEL, "Disk2"}, {STRATEGY_NONE, "Custom"}};

const map<int, string> stringByStrategyId = {{STRATEGY_DEFAULT, "DEFAULT"},
{STRATEGY_ETHERNET, "MAC"},
{STRATEGY_IP_ADDRESS, "IP"},
{STRATEGY_DISK_NUM, "Disk1"},
{STRATEGY_DISK_LABEL, "Disk2"}};

const unordered_map<int, string> descByVirtDetail = {{BARE_TO_METAL, "No virtualization"},
{VMWARE, "Vmware"},
Expand Down
4 changes: 2 additions & 2 deletions src/library/base/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ std::vector<uint8_t> unbase64(const std::string& base64_data) {
int cb = 0;
int charNo;
int pad = 0;
int len = tmp_str.size();
size_t len = tmp_str.size();

if (len < 2) { // 2 accesses below would be OOB.
// catch empty string, return NULL as result.
Expand All @@ -121,7 +121,7 @@ std::vector<uint8_t> unbase64(const std::string& base64_data) {
if (safeAsciiPtr[len - 1] == '=') ++pad;
if (safeAsciiPtr[len - 2] == '=') ++pad;

unsigned int flen = 3 * len / 4 - pad;
size_t flen = 3 * len / 4 - pad;
bin.reserve(flen);

for (charNo = 0; charNo <= len - 4 - pad; charNo += 4) {
Expand Down
6 changes: 2 additions & 4 deletions src/library/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ IF(UNIX OR OPENSSL_FOUND)
linux/cpu_info.cpp
linux/network.cpp
linux/os-linux.cpp)

target_link_libraries(os PUBLIC OpenSSL::Crypto)
ELSE(UNIX)
#windows and openssl
add_library(os OBJECT
cpu_info_common.cpp windows/cpu_info.cpp
openssl/signature_verifier.cpp
Expand All @@ -19,9 +18,8 @@ IF(UNIX OR OPENSSL_FOUND)
windows/isvm/BIOSReader.cpp
windows/os-win.cpp
windows/network.cpp)

target_link_libraries(os PUBLIC OpenSSL::Crypto)
ENDIF(UNIX)
target_include_directories(os PUBLIC ${OPENSSL_INCLUDE_DIR})
ELSE(UNIX OR OPENSSL_FOUND)
#windows no openssl
add_library(os OBJECT
Expand Down
9 changes: 5 additions & 4 deletions src/library/os/windows/isvm/Native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,14 @@ bool InitEntryPoints()
return true;
}

void *LocateSMBIOS(uint32_t *smbios_size)
{
void *LocateSMBIOS(uint32_t *smbios_size) {
void *buf = NULL;
const DWORD tableSignature = ('R' << 24) | ('S' << 16) | ('M' << 8) | 'B';

if (bIsWindowsXPLater)
{
uint32_t size = 0;
size = Win32GetSystemFirmwareTable('RSMB', 0, buf, size);
size = Win32GetSystemFirmwareTable(tableSignature, 0, buf, size);
if (0 == size)
{
return NULL;
Expand All @@ -347,7 +348,7 @@ void *LocateSMBIOS(uint32_t *smbios_size)
buf = malloc(size);
if (buf)
{
if (0 == Win32GetSystemFirmwareTable('RSMB', 0, buf, size))
if (0 == Win32GetSystemFirmwareTable(tableSignature, 0, buf, size))
{
free(buf);
buf = NULL;
Expand Down
25 changes: 12 additions & 13 deletions src/library/os/windows/os-win.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/*#ifdef _MSC_VER
#include <Windows.h>
#endif*/
#include "../../base/logger.h"
#include "../os.h"

#define NOMINMAX
#include <windows.h>
#include <algorithm>
#include <licensecc/datatypes.h>
#include <iphlpapi.h>
#include <stdio.h>
//#pragma comment(lib, "IPHLPAPI.lib")

unsigned char* unbase64(const char* ascii, int len, int *flen);
#include "../../base/logger.h"
#include "../os.h"
using namespace std;

FUNCTION_RETURN getMachineName(unsigned char identifier[6]) {
FUNCTION_RETURN result = FUNC_RET_ERROR;
Expand All @@ -33,7 +31,7 @@ FUNCTION_RETURN getCpuId(unsigned char identifier[6]) {
//bug check return with diskinfos == null func_ret_ok
FUNCTION_RETURN getDiskInfos(DiskInfo * diskInfos, size_t * disk_info_size) {
DWORD fileMaxLen;
int ndrives = 0;
size_t ndrives = 0;
DWORD fileFlags;
char volName[MAX_PATH], fileSysName[MAX_PATH];
DWORD volSerial = 0;
Expand Down Expand Up @@ -63,10 +61,11 @@ FUNCTION_RETURN getDiskInfos(DiskInfo * diskInfos, size_t * disk_info_size) {
LOG_DEBUG("Filesystem : %s", fileSysName);
if (diskInfos != NULL) {
if (ndrives < (int)*disk_info_size) {
diskInfos[ndrives].id = ndrives;
strncpy(diskInfos[ndrives].device, volName, cmin(MAX_PATH, sizeof(volName)) - 1);
diskInfos[ndrives].id = (int)ndrives;
strncpy(diskInfos[ndrives].device, volName,
min(std::size_t{MAX_PATH}, sizeof(volName)) - 1);
strncpy(diskInfos[ndrives].label, fileSysName,
cmin(sizeof(diskInfos[ndrives].label), sizeof(fileSysName)) - 1);
min(sizeof(diskInfos[ndrives].label), sizeof(fileSysName)) - 1);
memcpy(diskInfos[ndrives].disk_sn, &volSerial, sizeof(DWORD));
diskInfos[ndrives].preferred = (szSingleDrive[0] == 'C');
} else {
Expand All @@ -92,7 +91,7 @@ FUNCTION_RETURN getDiskInfos(DiskInfo * diskInfos, size_t * disk_info_size) {
}
*disk_info_size = ndrives;
} else {
*disk_info_size = cmin(ndrives, *disk_info_size);
*disk_info_size = min(ndrives, *disk_info_size);
}
return return_value;
}
Expand Down
4 changes: 4 additions & 0 deletions test/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ target_link_libraries(
Boost::system
)

if(CODE_COVERAGE AND UNIX)
target_link_libraries(test_event_registry gcov)
endif(CODE_COVERAGE AND UNIX)

ADD_TEST(NAME test_license_reader COMMAND test_license_reader)
ADD_TEST(NAME test_license_locator COMMAND test_license_locator)
ADD_TEST(NAME test_event_registry COMMAND test_event_registry)
Expand Down
6 changes: 3 additions & 3 deletions test/library/os/execution_environment_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include <licensecc_properties.h>
#include <licensecc_properties_test.h>
#include "../../src/library/base/StringUtils.h"
#include "../../src/library/os/network.hpp"
#include "../../src/library/os/execution_environment.hpp"
#include "../../../src/library/base/StringUtils.h"
#include "../../../src/library/os/network.hpp"
#include "../../../src/library/os/execution_environment.hpp"

namespace license {
namespace os {
Expand Down
6 changes: 3 additions & 3 deletions test/library/os/network_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include <licensecc_properties.h>
#include <licensecc_properties_test.h>
#include "../../src/library/base/StringUtils.h"
#include "../../src/library/os/network.hpp"
#include "../../src/library/os/execution_environment.hpp"
#include "../../../src/library/base/StringUtils.h"
#include "../../../src/library/os/network.hpp"
#include "../../../src/library/os/execution_environment.hpp"

namespace license {
namespace os {
Expand Down

0 comments on commit a7d354a

Please sign in to comment.