Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lavabit/magma.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLadar Levison <ladar@lavabit.com>2018-09-18 21:58:54 +0300
committerLadar Levison <ladar@lavabit.com>2018-09-18 21:58:54 +0300
commitb39574310262231ffef63b141df8a7d4844eab68 (patch)
treec039b1971a94dd0f6f58352f487b84f80600b886 /src
parent3f3915dede4b09316feacf0c7c24c313c1222fe7 (diff)
Logic errors identified by static code analysis.
Diffstat (limited to 'src')
-rw-r--r--src/core/host/ip.c2
-rw-r--r--src/network/clients.c4
-rw-r--r--src/providers/cryptography/ecies.c2
-rw-r--r--src/providers/deprecated/ecies.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/core/host/ip.c b/src/core/host/ip.c
index 89ceef5c..fb09ad32 100644
--- a/src/core/host/ip.c
+++ b/src/core/host/ip.c
@@ -19,7 +19,7 @@ int_t ip_family(ip_t *address) {
int_t result = -1;
// Valid structures, with what appear to be invalid address families result in AF_UNSPEC.
- if (address && (address->family < AF_UNSPEC || address->family >= AF_MAX)) {
+ if (address && (address->family <= AF_UNSPEC || address->family >= AF_MAX)) {
result = AF_UNSPEC;
}
else if (address) {
diff --git a/src/network/clients.c b/src/network/clients.c
index 97eea9ab..c2e73928 100644
--- a/src/network/clients.c
+++ b/src/network/clients.c
@@ -29,7 +29,7 @@ int_t client_status(client_t *client) {
result = client->status;
}
// We return -1 if the status is already negative, or connection is otherwise invalid.
- else {
+ else if (client) {
result = client->status = -1;
}
@@ -142,7 +142,7 @@ client_t * client_connect(chr_t *host, uint32_t port) {
if (ret) {
log_pedantic("We were unable to connect with the host %s:%u. { connect = %i / errno = %s }",
host, port, ret, strerror_r(errno, MEMORYBUF(1024), 1024));
- close(sd);
+// close(sd);
return NULL;
}
diff --git a/src/providers/cryptography/ecies.c b/src/providers/cryptography/ecies.c
index 485f9b44..5e5b6b88 100644
--- a/src/providers/cryptography/ecies.c
+++ b/src/providers/cryptography/ecies.c
@@ -413,7 +413,7 @@ cryptex_t * deprecated_ecies_encrypt(stringer_t *key, ECIES_KEY_TYPE key_type, u
EVP_CIPHER_CTX cipher;
unsigned int mac_length;
EC_KEY *user, *ephemeral;
- size_t envelope_length, block_length, key_length, hexkey_length;
+ size_t envelope_length = 0, block_length = 0, key_length = 0, hexkey_length = 0;
uchr_t *kbuf;
unsigned char envelope_key[SHA512_DIGEST_LENGTH], iv[EVP_MAX_IV_LENGTH], block[EVP_MAX_BLOCK_LENGTH];
diff --git a/src/providers/deprecated/ecies.c b/src/providers/deprecated/ecies.c
index 43217c42..075e349c 100644
--- a/src/providers/deprecated/ecies.c
+++ b/src/providers/deprecated/ecies.c
@@ -414,7 +414,7 @@ cryptex_t * ecies_encrypt(stringer_t *key, ECIES_KEY_TYPE key_type, unsigned cha
EVP_CIPHER_CTX cipher;
unsigned int mac_length;
EC_KEY *user, *ephemeral;
- size_t envelope_length, block_length, key_length, hexkey_length;
+ size_t envelope_length = 0, block_length = 0, key_length = 0, hexkey_length = 0;
uchr_t *kbuf;
unsigned char envelope_key[SHA512_DIGEST_LENGTH], iv[EVP_MAX_IV_LENGTH], block[EVP_MAX_BLOCK_LENGTH];