Skip to content

Commit

Permalink
fix bug that causes some warnings during compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
richkmeli committed Aug 30, 2017
1 parent 8e6944f commit 4143ef3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2016 Riccardo Melioli. All Rights Reserved.
*/

#include <iostream>
#include "src/richkware.h"

int main() {
Expand Down
6 changes: 3 additions & 3 deletions src/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -461,7 +461,7 @@ std::string Blowfish::Encrypt(const std::string &src) const {
dst.push_back(static_cast<char>(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<uint32_t *>(dst.data())[i * 2];
uint32_t *right = &reinterpret_cast<uint32_t *>(dst.data())[i * 2 + 1];
EncryptBlock(left, right);
Expand All @@ -473,7 +473,7 @@ std::string Blowfish::Encrypt(const std::string &src) const {
std::string Blowfish::Decrypt(const std::string &src) const {
std::vector<char> 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<uint32_t *>(dst.data())[i * 2];
uint32_t *right = &reinterpret_cast<uint32_t *>(dst.data())[i * 2 + 1];
DecryptBlock(left, right);
Expand Down
2 changes: 1 addition & 1 deletion src/richkware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4143ef3

Please sign in to comment.