From 4143ef3638f1dbc569173f7c094c39f9673e87d9 Mon Sep 17 00:00:00 2001 From: Riccardo Melioli Date: Wed, 30 Aug 2017 21:03:59 +0200 Subject: [PATCH] fix bug that causes some warnings during compiling. --- main.cpp | 1 + src/crypto.cpp | 6 +++--- src/richkware.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 723d062..9441a45 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ * Copyright 2016 Riccardo Melioli. All Rights Reserved. */ +#include #include "src/richkware.h" int main() { diff --git a/src/crypto.cpp b/src/crypto.cpp index 43ce575..0147761 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -381,7 +381,7 @@ namespace { return 0; char length = data[data.size() - 1]; if (length > 0 && length <= 8) { - for (size_t i = 0; i < length; ++i) { + for (size_t i = 0; i < (unsigned int)length; ++i) { if (length != data[data.size() - i - 1]) { return 0; } @@ -461,7 +461,7 @@ std::string Blowfish::Encrypt(const std::string &src) const { dst.push_back(static_cast(padding_length)); } - for (int i = 0; i < dst.size() / sizeof(uint64_t); ++i) { + for (unsigned int i = 0; i < dst.size() / sizeof(uint64_t); ++i) { uint32_t *left = &reinterpret_cast(dst.data())[i * 2]; uint32_t *right = &reinterpret_cast(dst.data())[i * 2 + 1]; EncryptBlock(left, right); @@ -473,7 +473,7 @@ std::string Blowfish::Encrypt(const std::string &src) const { std::string Blowfish::Decrypt(const std::string &src) const { std::vector dst(src.begin(), src.end()); - for (int i = 0; i < dst.size() / sizeof(uint64_t); ++i) { + for (unsigned int i = 0; i < dst.size() / sizeof(uint64_t); ++i) { uint32_t *left = &reinterpret_cast(dst.data())[i * 2]; uint32_t *right = &reinterpret_cast(dst.data())[i * 2 + 1]; DecryptBlock(left, right); diff --git a/src/richkware.cpp b/src/richkware.cpp index 0f327fd..3613603 100644 --- a/src/richkware.cpp +++ b/src/richkware.cpp @@ -150,7 +150,7 @@ Richkware::Richkware(const char *AppNameArg, const char *defaultEncryptionKey, c Network network1(defaultEncryptionKey); encKey = network1.KeyExchange(serverAddress, port); - if (encKey.empty()) { + if (encKey.empty() || (encKey.compare("Error") == 0)) { // Key Exchange failed encryptionKey = defaultEncryptionKey; } else {