From c914d298604ef7ad3934c3c213d3f8822d6646d9 Mon Sep 17 00:00:00 2001
From: Guillaume Buisson <contact@guillaume.dev>
Date: 摹曛, 20 5月 2021 13:50:43 +0800
Subject: [PATCH] Several fixes (#120)

---
 src/library/base/base64.cpp |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/library/base/base64.cpp b/src/library/base/base64.cpp
index a8f1c4c..4eaf10e 100644
--- a/src/library/base/base64.cpp
+++ b/src/library/base/base64.cpp
@@ -39,7 +39,7 @@
 };  // This array has 255 elements
 
 // review api
-void add_CR_if_needed(string& encodeBuffer, int lineLenght) {
+static void add_CR_if_needed(string& encodeBuffer, int lineLenght) {
 	if (lineLenght > 0 && ((encodeBuffer.size() + 1) % lineLenght) == 0) {
 		encodeBuffer += '\n';
 	}
@@ -48,8 +48,8 @@
 string base64(const void* binaryData, size_t len, int lineLenght) {
 	const unsigned char* bin = (const unsigned char*)binaryData;
 
-	int rc = 0;  // result counter
-	int byteNo;  // I need this after the loop
+	// int rc = 0;  // result counter
+	unsigned int byteNo;  // I need this after the loop
 
 	int modulusLen = len % 3;
 	int pad = ((modulusLen & 1) << 1) + ((modulusLen & 2) >> 1);  // 2 gives 1 and 1 gives 2, but 0 gives 0.
@@ -108,10 +108,10 @@
 	tmp_str.erase(std::remove(tmp_str.begin(), tmp_str.end(), '\n'), tmp_str.end());
 	const unsigned char* safeAsciiPtr = (const unsigned char*)tmp_str.c_str();
 	std::vector<uint8_t> bin;
-	int cb = 0;
-	int charNo;
+	// int cb = 0;
+	unsigned int charNo;
 	int pad = 0;
-	int len = tmp_str.size();
+	size_t len = tmp_str.size();
 
 	if (len < 2) {  // 2 accesses below would be OOB.
 		// catch empty string, return NULL as result.
@@ -121,7 +121,7 @@
 	if (safeAsciiPtr[len - 1] == '=') ++pad;
 	if (safeAsciiPtr[len - 2] == '=') ++pad;
 
-	unsigned int flen = 3 * len / 4 - pad;
+	size_t flen = 3 * len / 4 - pad;
 	bin.reserve(flen);
 
 	for (charNo = 0; charNo <= len - 4 - pad; charNo += 4) {

--
Gitblit v1.9.1