From 4093b38f678b4d253b610f3439adb9e950e37c92 Mon Sep 17 00:00:00 2001
From: Jan Willamowius <jan@willamowius.de>
Date: 周一, 22 4月 2019 23:56:28 +0800
Subject: [PATCH] fix regex to check format of client signature

---
 src/library/LicenseReader.cpp |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp
index 7b1ae65..2c6a179 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);
@@ -91,9 +89,10 @@
 			license->expiry_date[0] = '\0';
 			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()));
+			strncpy(license->expiry_date, to_date.c_str(), 11-1);
+			double secs = difftime(
+				seconds_from_epoch(to_date.c_str()),
+				time(NULL));
 			license->days_left = (int) secs / 60 * 60 * 24;
 		}
 	}

--
Gitblit v1.9.1