From 51213b102296c1e48f25aa9472a8be74a31cb6b7 Mon Sep 17 00:00:00 2001 From: Jan Willamowius <jan@willamowius.de> Date: 周一, 22 4月 2019 01:58:13 +0800 Subject: [PATCH] fix gcc 5.4 warnings --- 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 10c51b2..8353f55 100644 --- a/src/library/pc-identifiers.c +++ b/src/library/pc-identifiers.c @@ -153,7 +153,7 @@ return result_diskinfos; } diskInfos = (DiskInfo*) malloc(disk_num * sizeof(DiskInfo)); - //memset(diskInfos,0,disk_num * sizeof(DiskInfo)); + memset(diskInfos,0,disk_num * sizeof(DiskInfo)); result_diskinfos = getDiskInfos(diskInfos, &disk_num); if (result_diskinfos != FUNC_RET_OK) { free(diskInfos); @@ -179,7 +179,7 @@ if (use_label) { if (diskInfos[i].label[0] != 0) { memset(identifiers[j], 0, sizeof(PcIdentifier)); //!!!!!!! - strncpy(identifiers[j], diskInfos[i].label, + strncpy((char*)identifiers[j], diskInfos[i].label, sizeof(PcIdentifier)); j++; } @@ -281,7 +281,7 @@ PcSignature pc_identifier_out) { //TODO base62 encoding, now uses base64 PcIdentifier concat_identifiers[2]; - char* b64_data; + char* b64_data = NULL; int b64_size = 0; size_t concatIdentifiersSize = sizeof(PcIdentifier) * 2; //concat_identifiers = (PcIdentifier *) malloc(concatIdentifiersSize); @@ -289,6 +289,7 @@ memcpy(&concat_identifiers[1], identifier2, sizeof(PcIdentifier)); b64_data = base64(concat_identifiers, concatIdentifiersSize, &b64_size); if (b64_size > sizeof(PcSignature)) { + free(b64_data); return FUNC_RET_BUFFER_TOO_SMALL; } sprintf(pc_identifier_out, "%.4s-%.4s-%.4s-%.4s", &b64_data[0], @@ -345,7 +346,7 @@ PcIdentifier identifier2_out, PcSignature pc_signature_in) { //TODO base62 encoding, now uses base64 - unsigned char * concat_identifiers; + unsigned char * concat_identifiers = NULL; char base64ids[17]; int identifiers_size; @@ -353,6 +354,7 @@ &base64ids[8], &base64ids[12]); concat_identifiers = unbase64(base64ids, 16, &identifiers_size); if (identifiers_size > sizeof(PcIdentifier) * 2) { + free(concat_identifiers); return FUNC_RET_BUFFER_TOO_SMALL; } memcpy(identifier1_out, concat_identifiers, sizeof(PcIdentifier)); @@ -386,6 +388,7 @@ for (i = 0; i < 2; i++) { current_strategy_id = strategy_from_pc_id(user_identifiers[i]); if (current_strategy_id == STRATEGY_UNKNOWN) { + free(calculated_identifiers); return LICENSE_MALFORMED; } if (current_strategy_id != previous_strategy_id) { -- Gitblit v1.9.1