From fe99eb02df77db61b2553db8e36d326c7747caeb Mon Sep 17 00:00:00 2001 From: thorkill Date: Tue, 30 Jun 2015 18:08:31 +0200 Subject: [PATCH] Revert "Still hunting down uninitialized variables" This reverts commit 46b9578caddf9fbed587d4bc21ebbd7b1ba7e726. --- src/event.c | 7 +------ src/protocol_auth.c | 7 +++---- src/protocol_key.c | 24 ++++-------------------- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/event.c b/src/event.c index 032f1a23..1f42c68d 100644 --- a/src/event.c +++ b/src/event.c @@ -259,15 +259,10 @@ bool event_loop(void) { while(running) { struct timeval diff; - struct timeval *tv = NULL; - - - memset(&diff, 0x0, sizeof diff); + struct timeval *tv = get_time_remaining(&diff); memcpy(&readable, &readfds, sizeof readable); memcpy(&writable, &writefds, sizeof writable); - tv = get_time_remaining(&diff); - int fds = 0; if(io_tree.tail) { diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 6782226b..78c19ba3 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -498,11 +498,10 @@ bool metakey_h(connection_t *c, const char *request) { char enckey[len]; char key[len]; - memset(&key, 0x0, len); - memset(&enckey, 0x0, len); - memset(&hexkey,0x0, MAX_STRING_SIZE); + bzero(key, len); + bzero(enckey, len); - cipher = digest = maclength = compression = -1; + cipher = digest = maclength =compression = 0; if(sscanf(request, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, hexkey) != 5) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, c->hostname); diff --git a/src/protocol_key.c b/src/protocol_key.c index c0792dd3..eb64711d 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -58,7 +58,7 @@ void send_key_changed(void) { bool key_changed_h(connection_t *c, const char *request) { char name[MAX_STRING_SIZE]; node_t *n; - memset(&name, 0x0, MAX_STRING_SIZE); + if(sscanf(request, "%*d %*x " MAX_STRING, name) != 1) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "KEY_CHANGED", c->name, c->hostname); @@ -136,7 +136,6 @@ static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, no char buf[MAX_STRING_SIZE]; int len; - memset(&buf, 0x0, MAX_STRING_SIZE); if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s) to %s (%s): %s", "SPTPS_PACKET", from->name, from->hostname, to->name, to->hostname, "invalid SPTPS data"); return true; @@ -191,7 +190,6 @@ static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, no } char pubkey[MAX_STRING_SIZE]; - memset(&pubkey, 0x0, MAX_STRING_SIZE); if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, pubkey) != 1 || !(from->ecdsa = ecdsa_set_base64_public_key(pubkey))) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ANS_PUBKEY", from->name, from->hostname, "invalid pubkey"); return true; @@ -213,9 +211,7 @@ static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, no logger(DEBUG_ALWAYS, LOG_DEBUG, "Got REQ_KEY from %s while we already started a SPTPS session!", from->name); char buf[MAX_STRING_SIZE]; - int len = -1; - - memset(&buf, 0x0, MAX_STRING_SIZE); + int len; if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_SPTPS_START", from->name, from->hostname, "invalid SPTPS data"); @@ -246,9 +242,6 @@ bool req_key_h(connection_t *c, const char *request) { node_t *from, *to; int reqno = 0; - memset(&from_name, 0x0, MAX_STRING_SIZE); - memset(&to_name, 0x0, MAX_STRING_SIZE); - if(sscanf(request, "%*d " MAX_STRING " " MAX_STRING " %d", from_name, to_name, &reqno) < 2) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "REQ_KEY", c->name, c->hostname); @@ -361,20 +354,11 @@ bool ans_key_h(connection_t *c, const char *request) { char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; char key[MAX_STRING_SIZE]; - char address[MAX_STRING_SIZE]; - char port[MAX_STRING_SIZE]; + char address[MAX_STRING_SIZE] = ""; + char port[MAX_STRING_SIZE] = ""; int cipher, digest, maclength, compression, keylen; node_t *from, *to; - from = to = NULL; - - cipher = digest = maclength = compression = keylen = -1; - memset(&from_name, 0x0, MAX_STRING_SIZE); - memset(&to_name, 0x0, MAX_STRING_SIZE); - memset(&key, 0x0, MAX_STRING_SIZE); - memset(&address, 0x0, MAX_STRING_SIZE); - memset(&port, 0x0, MAX_STRING_SIZE); - if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, from_name, to_name, key, &cipher, &digest, &maclength, &compression, address, port) < 7) {