summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE2
-rw-r--r--Makefile.am10
-rw-r--r--changes/bug70293
-rw-r--r--src/common/aes.c16
-rw-r--r--src/common/include.am2
-rw-r--r--src/ext/README31
-rw-r--r--src/ext/include.am4
-rw-r--r--src/ext/strlcat.c (renamed from src/common/strlcat.c)0
-rw-r--r--src/ext/strlcpy.c (renamed from src/common/strlcpy.c)0
-rw-r--r--src/or/channel.c31
-rw-r--r--src/or/circuitbuild.c1
-rw-r--r--src/or/command.c2
-rw-r--r--src/or/config.c3
-rw-r--r--src/or/connection.c3
-rw-r--r--src/or/dirserv.c3
-rw-r--r--src/or/main.c4
-rw-r--r--src/or/rephist.c2
17 files changed, 97 insertions, 20 deletions
diff --git a/LICENSE b/LICENSE
index bf90e614ae..47eaf974a2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -43,7 +43,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===============================================================================
-src/common/strlcat.c and src/common/strlcpy.c by Todd C. Miller are licensed
+src/ext/strlcat.c and src/ext/strlcpy.c by Todd C. Miller are licensed
under the following license:
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
diff --git a/Makefile.am b/Makefile.am
index 787be4951c..2854763d25 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,13 +62,9 @@ test: all
# eventdns.[hc], tinytest*.[ch]
check-spaces:
./contrib/checkSpace.pl -C \
- src/common/*.h \
- src/common/[^asO]*.c \
- src/common/address.c \
- src/or/[^e]*.[ch] \
- src/or/eventdns_tor.h \
- src/test/test*.[ch] \
- src/test/[^t]*.[ch] \
+ src/common/*.[ch] \
+ src/or/*.[ch] \
+ src/test/*.[ch] \
src/tools/*.[ch] \
src/tools/tor-fw-helper/*.[ch]
diff --git a/changes/bug7029 b/changes/bug7029
new file mode 100644
index 0000000000..a115b42f8e
--- /dev/null
+++ b/changes/bug7029
@@ -0,0 +1,3 @@
+ o Minor bugfixes (code cleanliness):
+ - Free some more still-in-use memory at exit, to make hunting for
+ memory leaks easier. Resolves bug 7029.
diff --git a/src/common/aes.c b/src/common/aes.c
index 9547de4eb3..8e489baae1 100644
--- a/src/common/aes.c
+++ b/src/common/aes.c
@@ -340,7 +340,7 @@ aes_set_key(aes_cnt_cipher_t *cipher, const char *key, int key_bits)
EVP_EncryptInit(&cipher->key.evp, c, (const unsigned char*)key, NULL);
cipher->using_evp = 1;
} else {
- AES_set_encrypt_key((const unsigned char *)key, key_bits, &cipher->key.aes);
+ AES_set_encrypt_key((const unsigned char *)key, key_bits,&cipher->key.aes);
cipher->using_evp = 0;
}
@@ -387,9 +387,10 @@ aes_cipher_free(aes_cnt_cipher_t *cipher)
#ifdef CAN_USE_OPENSSL_CTR
/* Helper function to use EVP with openssl's counter-mode wrapper. */
-static void evp_block128_fn(const uint8_t in[16],
- uint8_t out[16],
- const void *key)
+static void
+evp_block128_fn(const uint8_t in[16],
+ uint8_t out[16],
+ const void *key)
{
EVP_CIPHER_CTX *ctx = (void*)key;
int inl=16, outl=16;
@@ -429,8 +430,7 @@ aes_crypt(aes_cnt_cipher_t *cipher, const char *input, size_t len,
&cipher->pos);
}
return;
- }
- else
+ } else
#endif
{
int c = cipher->pos;
@@ -469,8 +469,7 @@ aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len)
if (should_use_openssl_CTR) {
aes_crypt(cipher, data, len, data);
return;
- }
- else
+ } else
#endif
{
int c = cipher->pos;
@@ -519,3 +518,4 @@ aes_set_iv(aes_cnt_cipher_t *cipher, const char *iv)
}
#endif
+
diff --git a/src/common/include.am b/src/common/include.am
index 7299a47afb..0fdc72057f 100644
--- a/src/common/include.am
+++ b/src/common/include.am
@@ -47,8 +47,6 @@ COMMONHEADERS = \
src/common/memarea.h \
src/common/mempool.h \
src/common/procmon.h \
- src/common/strlcat.c \
- src/common/strlcpy.c \
src/common/torgzip.h \
src/common/torint.h \
src/common/torlog.h \
diff --git a/src/ext/README b/src/ext/README
new file mode 100644
index 0000000000..07db3c1338
--- /dev/null
+++ b/src/ext/README
@@ -0,0 +1,31 @@
+
+OpenBSD_malloc_Linux.c:
+
+ The OpenBSD malloc implementation, ported to Linux. Used only when
+ --enable-openbsd-malloc is passed to the configure script.
+
+strlcat.c
+strlcpy.c
+
+ Implementations of strlcat and strlcpy, the more sane replacements
+ for strcat and strcpy. These are nonstandard, and some libc
+ implementations refuse to add them for religious reasons.
+
+eventdns.[ch]
+
+ A fork of Libevent's DNS implementation, used by Tor when Libevent
+ 2.0 or later is not available. Once Libevent 2.0 is required, we
+ should throw this away; it has diverged from evdns.[ch], and is
+ no longer easily mergeable.
+
+ht.h
+
+ An implementation of a hash table in the style of Niels Provos's
+ tree.h. Shared with Libevent.
+
+tinytest.[ch]
+tinytest_demos.c
+tinytest_macros.h
+
+ A unit testing framework. https://github.com/nmathewson/tinytest
+
diff --git a/src/ext/include.am b/src/ext/include.am
index 97e7e46b46..fa9ee94020 100644
--- a/src/ext/include.am
+++ b/src/ext/include.am
@@ -1,10 +1,14 @@
AM_CPPFLAGS += -I$(srcdir)/src/ext -Isrc/ext
+EXTRA_DIST += src/ext/README
+
EXTHEADERS = \
src/ext/ht.h \
src/ext/eventdns.h \
src/ext/tinytest.h \
+ src/ext/strlcat.c \
+ src/ext/strlcpy.c \
src/ext/tinytest_macros.h
noinst_HEADERS+= $(EXTHEADERS)
diff --git a/src/common/strlcat.c b/src/ext/strlcat.c
index 316733bccc..316733bccc 100644
--- a/src/common/strlcat.c
+++ b/src/ext/strlcat.c
diff --git a/src/common/strlcpy.c b/src/ext/strlcpy.c
index 9fc47903a1..9fc47903a1 100644
--- a/src/common/strlcpy.c
+++ b/src/ext/strlcpy.c
diff --git a/src/or/channel.c b/src/or/channel.c
index 10ea0d8a7b..d0e36cd282 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -808,11 +808,24 @@ channel_free(channel_t *chan)
/* It must be deregistered */
tor_assert(!(chan->registered));
+ log_debug(LD_CHANNEL,
+ "Freeing channel " U64_FORMAT " at %p",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+
+ /*
+ * Get rid of cmux policy before we do anything, so cmux policies don't
+ * see channels in weird half-freed states.
+ */
+ if (chan->cmux) {
+ circuitmux_set_policy(chan->cmux, NULL);
+ }
+
/* Call a free method if there is one */
if (chan->free) chan->free(chan);
channel_clear_remote_end(chan);
+ /* Get rid of cmux */
if (chan->cmux) {
circuitmux_detach_all_circuits(chan->cmux);
circuitmux_free(chan->cmux);
@@ -863,11 +876,29 @@ channel_force_free(channel_t *chan)
{
tor_assert(chan);
+ log_debug(LD_CHANNEL,
+ "Force-freeing channel " U64_FORMAT " at %p",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+
+ /*
+ * Get rid of cmux policy before we do anything, so cmux policies don't
+ * see channels in weird half-freed states.
+ */
+ if (chan->cmux) {
+ circuitmux_set_policy(chan->cmux, NULL);
+ }
+
/* Call a free method if there is one */
if (chan->free) chan->free(chan);
channel_clear_remote_end(chan);
+ /* Get rid of cmux */
+ if (chan->cmux) {
+ circuitmux_free(chan->cmux);
+ chan->cmux = NULL;
+ }
+
/* We might still have a cell queue; kill it */
if (chan->incoming_queue) {
SMARTLIST_FOREACH_BEGIN(chan->incoming_queue,
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 18016ac71e..9287084cbb 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -5897,5 +5897,6 @@ entry_guards_free_all(void)
clear_bridge_list();
smartlist_free(bridge_list);
bridge_list = NULL;
+ circuit_build_times_free_timeouts(&circ_times);
}
diff --git a/src/or/command.c b/src/or/command.c
index b8d65b00b3..39eccdf82d 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -160,7 +160,7 @@ command_process_cell(channel_t *chan, cell_t *cell)
}
/** Process an incoming var_cell from a channel; in the current protocol all
- * the var_cells are handshake-related and handles below the channel layer,
+ * the var_cells are handshake-related and handled below the channel layer,
* so this just logs a warning and drops the cell.
*/
diff --git a/src/or/config.c b/src/or/config.c
index b1f51879ce..30376b86fa 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -676,6 +676,9 @@ config_free_all(void)
tor_free(torrc_defaults_fname);
tor_free(the_tor_version);
tor_free(global_dirfrontpagecontents);
+
+ tor_free(the_short_tor_version);
+ tor_free(the_tor_version);
}
/** Make <b>address</b> -- a piece of information related to our operation as
diff --git a/src/or/connection.c b/src/or/connection.c
index 9af7d320ed..b4589bfb07 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4327,6 +4327,9 @@ connection_free_all(void)
outgoing_addrs = NULL;
}
+ tor_free(last_interface_ipv4);
+ tor_free(last_interface_ipv6);
+
#ifdef USE_BUFFEREVENTS
if (global_rate_limit)
bufferevent_rate_limit_group_free(global_rate_limit);
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 8a32a82485..e7aa582cfc 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -93,7 +93,8 @@ static const signed_descriptor_t *get_signed_descriptor_by_fp(
const char *fp,
int extrainfo,
time_t publish_cutoff);
-static int dirserv_add_extrainfo(extrainfo_t *ei, const char **msg);
+static was_router_added_t dirserv_add_extrainfo(extrainfo_t *ei,
+ const char **msg);
/************** Measured Bandwidth parsing code ******/
#define MAX_MEASUREMENT_AGE (3*24*60*60) /* 3 days */
diff --git a/src/or/main.c b/src/or/main.c
index ad4734ea94..adc1f5d983 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2503,6 +2503,10 @@ tor_free_all(int postfork)
smartlist_free(closeable_connection_lst);
smartlist_free(active_linked_connection_lst);
periodic_timer_free(second_timer);
+#ifndef USE_BUFFEREVENTS
+ periodic_timer_free(refill_timer);
+#endif
+
if (!postfork) {
release_lockfile();
}
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 4889fd16c1..e61e599d7e 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -3003,6 +3003,8 @@ rep_hist_free_all(void)
digestmap_free(history_map, free_or_history);
tor_free(read_array);
tor_free(write_array);
+ tor_free(dir_read_array);
+ tor_free(dir_write_array);
tor_free(last_stability_doc);
tor_free(exit_bytes_read);
tor_free(exit_bytes_written);