From 6f5db32d147166ab1617c66844e3297eededc704 Mon Sep 17 00:00:00 2001
From: Gabriele Contini <gcontini@users.noreply.github.com>
Date: 摹曛, 19 9月 2019 20:20:18 +0800
Subject: [PATCH] Feature/mingw cross compile (#51)

---
 src/library/pc-identifiers.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/library/pc-identifiers.c b/src/library/pc-identifiers.c
index 68cc71d..0f39760 100644
--- a/src/library/pc-identifiers.c
+++ b/src/library/pc-identifiers.c
@@ -39,11 +39,11 @@
 
 	if (identifiers == NULL || *num_identifiers == 0) {
 		result_adapterInfos = getAdapterInfos(NULL, &adapter_num);
-		if (result_adapterInfos != FUNC_RET_OK) {
+		if ((result_adapterInfos != FUNC_RET_OK) || (adapter_num == 0)) {
 			return generate_disk_pc_id(identifiers, num_identifiers, false);
 		}
 		result_diskinfos = getDiskInfos(NULL, &disk_num);
-		if (result_diskinfos != FUNC_RET_OK) {
+		if ((result_diskinfos != FUNC_RET_OK) || (disk_num == 0)) {
 			return generate_ethernet_pc_id(identifiers, num_identifiers, true);
 		}
 		*num_identifiers = disk_num * adapter_num;
@@ -283,7 +283,7 @@
 	PcIdentifier concat_identifiers[2];
 	char* b64_data = NULL;
 	int b64_size = 0;
-	size_t concatIdentifiersSize = sizeof(PcIdentifier) * 2;
+	const size_t concatIdentifiersSize = sizeof(PcIdentifier) * 2;
 	//concat_identifiers = (PcIdentifier *) malloc(concatIdentifiersSize);
 	memcpy(&concat_identifiers[0], identifier1, sizeof(PcIdentifier));
 	memcpy(&concat_identifiers[1], identifier2, sizeof(PcIdentifier));
@@ -388,9 +388,12 @@
 	//found = false;
 	for (i = 0; i < 2; i++) {
 		current_strategy_id = strategy_from_pc_id(user_identifiers[i]);
-		if (current_strategy_id == STRATEGY_UNKNOWN) {
+		if (current_strategy_id == STRATEGY_UNKNOWN && previous_strategy_id == STRATEGY_UNKNOWN && i==1) {
 			free(calculated_identifiers);
+			printf("Comparing pc identifiers: %d %d %d %s\n",current_strategy_id,previous_strategy_id,i, str_code);
 			return LICENSE_MALFORMED;
+		} else if (current_strategy_id == STRATEGY_UNKNOWN ){
+			continue;
 		}
 		if (current_strategy_id != previous_strategy_id) {
 			if (calculated_identifiers != NULL) {

--
Gitblit v1.9.1