Jan Willamowius
2019-04-24 cd279f99fc3249c731ced737ca88fb66f9c3801c
fix switch to add extra_data to license, revert change that broke copying of nul byte at end of date
2个文件已修改
47 ■■■■■ 已修改文件
src/library/LicenseReader.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/license-generator/license-generator.cpp 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/LicenseReader.cpp
@@ -89,7 +89,7 @@
            license->expiry_date[0] = '\0';
            license->days_left = 999999;
        } else {
            strncpy(license->expiry_date, to_date.c_str(), 11-1);
            strncpy(license->expiry_date, to_date.c_str(), 11);
            double secs = difftime(
                seconds_from_epoch(to_date.c_str()),
                time(NULL));
@@ -160,9 +160,11 @@
                    FullLicenseInfo::UNUSED_SOFTWARE_VERSION);
            int to_sw_version = ini.GetLongValue(productNamePtr,
                    "to_sw_version", FullLicenseInfo::UNUSED_SOFTWARE_VERSION);
            string extra_data = trim_copy(
                    ini.GetValue(productNamePtr, "extra_data", ""));
            FullLicenseInfo licInfo(*it, product, license_signature,
                    (int) license_version, from_date, to_date, client_signature,
                    from_sw_version, to_sw_version);
                    from_sw_version, to_sw_version, extra_data);
            licenseInfoOut.push_back(licInfo);
            atLeastOneLicenseComplete = true;
        } else {
src/tools/license-generator/license-generator.cpp
@@ -40,31 +40,36 @@
po::options_description LicenseGenerator::configureProgramOptions() {
    po::options_description common("General options");
    common.add_options()("help,h", "print help message and exit.") //
    ("verbose,v", "print more information.") //
    ("output,o", po::value<string>(), "Output file name. If not specified the "
            "license will be printed in standard output"); //
    common.add_options()
        ("help,h", "print help message and exit.")
        ("verbose,v", "print more information.")
        ("output,o", po::value<string>(), "Output file name. If not specified the "
            "license will be printed in standard output")
        ;
    po::options_description licenseGeneration("License Generation");
    licenseGeneration.add_options()("private_key,p", po::value<string>(),
    licenseGeneration.add_options()
        ("private_key,p", po::value<string>(),
            "Specify an alternate file for the primary key to be used. "
                    "If not specified the internal primary key will be used.") //
    ("begin_date,b", po::value<string>(),
                    "If not specified the internal primary key will be used.")
        ("begin_date,b", po::value<string>(),
            "Specify the start of the validity for this license. "
                    " Format YYYYMMDD. If not specified defaults to today") //
    ("expire_date,e", po::value<string>(),
                    " Format YYYYMMDD. If not specified defaults to today")
        ("expire_date,e", po::value<string>(),
            "Specify the expire date for this license. "
                    " Format YYYYMMDD. If not specified the license won't expire") //
    ("client_signature,s", po::value<string>(),
                    " Format YYYYMMDD. If not specified the license won't expire")
        ("client_signature,s", po::value<string>(),
            "The signature of the pc that requires the license. "
                    "It should be in the format XXXX-XXXX-XXXX-XXXX."
                    " If not specified the license "
                    "won't be linked to a specific pc.") //
    ("start_version,t", po::value<unsigned int>()->default_value(0
    /*FullLicenseInfo.UNUSED_SOFTWARE_VERSION*/, "All Versions"),
            "Specify the first version of the software this license apply to.") //
    ("end_version,n", po::value<unsigned int>()->default_value(0
    /*FullLicenseInfo.UNUSED_SOFTWARE_VERSION*/, "All Versions"),
            "Specify the last version of the software this license apply to."); //
                    "won't be linked to a specific pc.")
        ("start_version,t", po::value<unsigned int>()->default_value(0
            /*FullLicenseInfo.UNUSED_SOFTWARE_VERSION*/, "All Versions"),
            "Specify the first version of the software this license apply to.")
        ("end_version,n", po::value<unsigned int>()->default_value(0
            /*FullLicenseInfo.UNUSED_SOFTWARE_VERSION*/, "All Versions"),
            "Specify the last version of the software this license apply to.")
        ("extra_data,x", po::value<string>(), "Specify extra data to be included into the license")
        ;
    po::options_description visibleOptions;
    visibleOptions.add(common).add(licenseGeneration);
    return visibleOptions;