gcontini
2019-09-07 726ec77becb3affbc5a5c872bea56c540cdb6e8c
Merge branch 'master' of https://github.com/open-license-manager/open-license-manager.git
8个文件已修改
60 ■■■■ 已修改文件
CMakeLists.txt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/LicenseReader.cpp 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/base/EventRegistry.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/license++.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/base_lib/win/CryptoHelperWindows.cpp 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/bootstrap/bootstrap.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/license-generator/license-generator.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/library/LicenseReader_test.cpp 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CMakeLists.txt
@@ -96,7 +96,9 @@
        include_directories(${DBUS_ARCH_INCLUDE_DIR})
        list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES})
    endif(USE_DBUS_IDENTIFIER)    
    list(APPEND EXTERNAL_LIBS dl)
    if(NOT MINGW)
        list(APPEND EXTERNAL_LIBS dl)
    endif(NOT MINGW)
    list(APPEND EXTERNAL_LIBS "-Wl,-Bdynamic")
endif(NOT MSVC)
src/library/LicenseReader.cpp
@@ -60,7 +60,7 @@
        er.addEvent(LICENSE_CORRUPTED, SVRT_ERROR);
    }
    if (has_expiry) {
        const time_t now = time(NULL);
        const time_t now = time(nullptr);
        if (expires_on() < now) {
            er.addEvent(PRODUCT_EXPIRED, SVRT_ERROR, "");
        }
@@ -80,7 +80,7 @@
}
void FullLicenseInfo::toLicenseInfo(LicenseInfo* license) const {
    if (license != NULL) {
    if (license != nullptr) {
        strncpy(license->proprietary_data, extra_data.c_str(),
        PROPRIETARY_DATA_SIZE);
@@ -93,7 +93,7 @@
            strncpy(license->expiry_date, to_date.c_str(), 11);
            const double secs = difftime(
                seconds_from_epoch(to_date.c_str()),
                time(NULL));
                time(nullptr));
            license->days_left = round(secs / (60 * 60 * 24));
        }
    }
@@ -141,10 +141,10 @@
         *  application_data = xxxxxxxxx (optional string 16)
         */
        const char * license_signature = ini.GetValue(productNamePtr,
                "license_signature", NULL);
        const long license_version = ini.GetLongValue(productNamePtr,
                "license_signature", nullptr);
        long license_version = ini.GetLongValue(productNamePtr,
                "license_version", -1);
        if (license_signature != NULL && license_version > 0) {
        if (license_signature != nullptr && license_version > 0) {
            const string from_date = trim_copy(
                    ini.GetValue(productNamePtr, "from_date",
                            FullLicenseInfo::UNUSED_TIME));
@@ -188,7 +188,7 @@
        EventRegistry& eventRegistry) {
//bool hasFileLocation = false;
    bool licenseFoundWithExplicitLocation = false;
    if (licenseLocation.licenseFileLocation != NULL
    if (licenseLocation.licenseFileLocation != nullptr
            && licenseLocation.licenseFileLocation[0] != '\0') {
        //hasFileLocation = true;
        const string varName(licenseLocation.licenseFileLocation);
@@ -213,13 +213,13 @@
bool LicenseReader::findFileWithEnvironmentVariable(vector<string>& diskFiles,
        EventRegistry& eventRegistry) {
    bool licenseFileFoundWithEnvVariable = false;
    if (licenseLocation.environmentVariableName != NULL
    if (licenseLocation.environmentVariableName != nullptr
            && licenseLocation.environmentVariableName[0] != '\0') {
        const string varName(licenseLocation.environmentVariableName);
        if (varName.length() > 0) {
            //var name is passed in by the calling application.
            char* env_var_value = getenv(varName.c_str());
            if (env_var_value != NULL && env_var_value[0] != '\0') {
            if (env_var_value != nullptr && env_var_value[0] != '\0') {
                const vector<string> declared_positions = splitLicensePositions(
                        string(env_var_value));
                vector<string> existing_pos = filterExistingFiles(
src/library/base/EventRegistry.cpp
@@ -51,7 +51,7 @@
}
AuditEvent const * EventRegistry::getLastFailure() const {
    const AuditEvent* result = NULL;
    const AuditEvent* result = nullptr;
    if (logs.size() == 0) {
        return result;
    }
src/library/license++.cpp
@@ -23,7 +23,7 @@
static void mergeLicenses(vector<license::FullLicenseInfo> licenses,
        LicenseInfo* license) {
    if (license != NULL) {
    if (license != nullptr) {
        time_t curLicense_exp = 0;
        for (auto it = licenses.begin(); it != licenses.end(); it++) {
            //choose the license that expires later...
@@ -68,7 +68,7 @@
    } else {
        result = er.getLastFailure()->event_type;
    }
    if (license != NULL) {
    if (license != nullptr) {
        er.exportLastEvents(license->status, 5);
    }
    return result;
src/tools/base_lib/win/CryptoHelperWindows.cpp
@@ -73,7 +73,7 @@
    HRESULT hr = S_OK;
    DWORD dwErrCode;
    DWORD dwBlobLen;
    BYTE *pbKeyBlob = NULL;
    BYTE *pbKeyBlob = nullptr;
    stringstream ss;
    // If the handle to key container is NULL, fail.
    if (m_hCryptKey == NULL)
@@ -82,14 +82,14 @@
    // blob.
    if (!CryptExportKey(m_hCryptKey,
    NULL, PUBLICKEYBLOB, 0,
    NULL, &dwBlobLen)) {
    nullptr, &dwBlobLen)) {
        dwErrCode = GetLastError();
        throw logic_error(
                string("Error calculating size of public key ")
                        + to_string(static_cast<long long>(dwErrCode)));
    }
    // Allocate memory for the pbKeyBlob.
    if ((pbKeyBlob = new BYTE[dwBlobLen]) == NULL) {
    if ((pbKeyBlob = new BYTE[dwBlobLen]) == nullptr) {
        throw logic_error(string("Out of memory exporting public key "));
    }
    // Do the actual exporting into the key BLOB.
@@ -142,14 +142,14 @@
    // blob.
    if (!CryptExportKey(m_hCryptKey,
    NULL, PRIVATEKEYBLOB, 0,
    NULL, &dwBlobLen)) {
    nullptr, &dwBlobLen)) {
        dwErrCode = GetLastError();
        throw logic_error(
                string("Error calculating size of private key ")
                        + to_string(static_cast<long long>(dwErrCode)));
    }
    // Allocate memory for the pbKeyBlob.
    if ((pbKeyBlob = new BYTE[dwBlobLen]) == NULL) {
    if ((pbKeyBlob = new BYTE[dwBlobLen]) == nullptr) {
        throw logic_error(string("Out of memory exporting private key "));
    }
@@ -243,7 +243,7 @@
    // Determine the size of the signature and allocate memory.
    dwSigLen = 0;
    if (CryptSignHash(hHash, AT_SIGNATURE, NULL, 0, NULL, &dwSigLen)) {
    if (CryptSignHash(hHash, AT_SIGNATURE, nullptr, 0, nullptr, &dwSigLen)) {
        printf("Signature length %d found.\n", dwSigLen);
    } else {
        throw logic_error(string("Error during CryptSignHash."));
@@ -260,7 +260,7 @@
    // Sign the hash object.
    if (CryptSignHash(hHash, AT_SIGNATURE,
    NULL, 0, pbSignature, &dwSigLen)) {
    nullptr, 0, pbSignature, &dwSigLen)) {
        printf("pbSignature is the signature length. %d\n", dwSigLen);
    } else {
        throw logic_error(string("Error during CryptSignHash."));
@@ -272,7 +272,7 @@
    CryptDestroyKey(hKey);
    CryptBinaryToString(pbSignature, dwSigLen,
            CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &strLen);
            CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, nullptr, &strLen);
    vector<char> buffer(strLen);
    CryptBinaryToString(pbSignature, dwSigLen,
            CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, &buffer[0], &strLen);
src/tools/bootstrap/bootstrap.cpp
@@ -10,7 +10,7 @@
void write_pubkey_file(const string& public_fname, const string& pbPublicKey) {
    FILE* fp = fopen(public_fname.c_str(), "w");
    if (fp == NULL) {
    if (fp == nullptr) {
        throw ios_base::failure(string("can't create :") + public_fname);
    }
    fprintf(fp, "//file generated by bootstrap.cpp, do not edit.\n\n");
@@ -26,7 +26,7 @@
void write_privkey_file(const string& private_fname, const string& privateKey) {
    FILE* fp = fopen(private_fname.c_str(), "w");
    if (fp == NULL) {
    if (fp == nullptr) {
        throw ios_base::failure(string("can't create :") + private_fname);
    }
    fprintf(fp, "//file generated by bootstrap.cpp, do not edit.\n\n");
src/tools/license-generator/license-generator.cpp
@@ -84,7 +84,7 @@
        try {
            end_date = normalize_date(dt_end);
            char curdate[20];
            time_t curtime = time(NULL);
            time_t curtime = time(nullptr);
            strftime(curdate, 20, "%Y-%m-%d", localtime(&curtime));
            begin_date.assign(curdate);
        } catch (const invalid_argument &e) {
test/library/LicenseReader_test.cpp
@@ -11,7 +11,7 @@
BOOST_AUTO_TEST_CASE( read_single_file ) {
    const char * licLocation =
    PROJECT_TEST_SRC_DIR "/library/test_reader.ini";
    const LicenseLocation location = { licLocation, NULL, false };
    const LicenseLocation location = { licLocation, nullptr, false };
    LicenseReader licenseReader(location);
    vector<FullLicenseInfo> licenseInfos;
    const EventRegistry registry = licenseReader.readLicenses("PrODUCT",
@@ -23,7 +23,7 @@
BOOST_AUTO_TEST_CASE( product_not_licensed ) {
    const char * licLocation =
    PROJECT_TEST_SRC_DIR "/library/test_reader.ini";
    const LicenseLocation location = { licLocation, NULL, false };
    const LicenseLocation location = { licLocation, nullptr, false };
    LicenseReader licenseReader(location);
    vector<FullLicenseInfo> licenseInfos;
    const EventRegistry registry = licenseReader.readLicenses("PRODUCT-NOT",
@@ -38,7 +38,7 @@
BOOST_AUTO_TEST_CASE( file_not_found ) {
    const char * licLocation = PROJECT_TEST_SRC_DIR "/library/not_found.ini";
    //const char * envName = "MYVAR";
    const LicenseLocation location = { licLocation, NULL, false };
    const LicenseLocation location = { licLocation, nullptr, false };
    LicenseReader licenseReader(location);
    vector<FullLicenseInfo> licenseInfos;
    const EventRegistry registry = licenseReader.readLicenses("PRODUCT",
@@ -52,7 +52,7 @@
BOOST_AUTO_TEST_CASE( env_var_not_defined ) {
    const char * envName = "MYVAR";
    const LicenseLocation location = { NULL, envName, false };
    const LicenseLocation location = {nullptr, envName, false };
    LicenseReader licenseReader(location);
    vector<FullLicenseInfo> licenseInfos;
    const EventRegistry registry = licenseReader.readLicenses("PRODUCT",
@@ -68,7 +68,7 @@
    char str[MAX_PATH];
    strcpy(str,"LIC_VAR=" PROJECT_TEST_SRC_DIR "/library/test_reader.ini");
    putenv(str);
    const LicenseLocation location = { NULL, "LIC_VAR", false };
    const LicenseLocation location = {nullptr, "LIC_VAR", false };
    LicenseReader licenseReader(location);
    vector<FullLicenseInfo> licenseInfos;
    const EventRegistry registry = licenseReader.readLicenses("PrODUCT",