From cd279f99fc3249c731ced737ca88fb66f9c3801c Mon Sep 17 00:00:00 2001 From: Jan Willamowius <jan@willamowius.de> Date: 周三, 24 4月 2019 05:33:23 +0800 Subject: [PATCH] fix switch to add extra_data to license, revert change that broke copying of nul byte at end of date --- src/library/LicenseReader.cpp | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp index 7b1ae65..d880979 100644 --- a/src/library/LicenseReader.cpp +++ b/src/library/LicenseReader.cpp @@ -25,8 +25,6 @@ #include "public-key.h" #include <build_properties.h> -#include "os/os-cpp.h" - namespace license { const char *FullLicenseInfo::UNUSED_TIME = "0000-00-00"; @@ -71,7 +69,7 @@ } if (has_client_sig) { PcSignature str_code; - strncpy(str_code, client_signature.c_str(), sizeof(str_code)); + strncpy(str_code, client_signature.c_str(), sizeof(str_code)-1); EVENT_TYPE event = validate_pc_signature(str_code); if (event != LICENSE_OK) { er.addEvent(event, SVRT_ERROR); @@ -92,8 +90,9 @@ license->days_left = 999999; } else { strncpy(license->expiry_date, to_date.c_str(), 11); - double secs = difftime(time(NULL), - seconds_from_epoch(to_date.c_str())); + double secs = difftime( + seconds_from_epoch(to_date.c_str()), + time(NULL)); license->days_left = (int) secs / 60 * 60 * 24; } } @@ -161,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 { -- Gitblit v1.9.1