diff options
-rw-r--r-- | changes/bug1831 | 8 | ||||
-rwxr-xr-x | contrib/checkSpace.pl | 4 | ||||
-rw-r--r-- | src/or/circuitbuild.c | 36 | ||||
-rw-r--r-- | src/or/circuitbuild.h | 2 | ||||
-rw-r--r-- | src/or/config.c | 4 | ||||
-rw-r--r-- | src/or/connection.c | 2 | ||||
-rw-r--r-- | src/or/connection_edge.c | 4 | ||||
-rw-r--r-- | src/or/control.c | 2 | ||||
-rw-r--r-- | src/or/cpuworker.c | 2 | ||||
-rw-r--r-- | src/or/dirvote.c | 8 | ||||
-rw-r--r-- | src/or/geoip.c | 2 | ||||
-rw-r--r-- | src/or/policies.c | 4 | ||||
-rw-r--r-- | src/or/relay.c | 2 | ||||
-rw-r--r-- | src/or/rendclient.c | 2 | ||||
-rw-r--r-- | src/test/test.c | 5 | ||||
-rw-r--r-- | src/test/test_dir.c | 2 |
16 files changed, 51 insertions, 38 deletions
diff --git a/changes/bug1831 b/changes/bug1831 new file mode 100644 index 0000000000..72f7d21856 --- /dev/null +++ b/changes/bug1831 @@ -0,0 +1,8 @@ + o Minor bugfixes + - Fix a memory leak in the error case of circuit_build_times_parse_state(). + Bugfix on 0.2.2.14-alpha; fixes bug 1831 partially. + - Fix a memory leak in dirvote_add_signatures_to_pending_consensus(). + Bugfix on 0.2.2.6-alpha; fixes bug 1831 partially. + - Fix a memory leak in dirvote_compute_consensuses(). + Bugfix on 0.2.0.3-alpha; fixes bug 1831 partially. + diff --git a/contrib/checkSpace.pl b/contrib/checkSpace.pl index b694abff64..6eb32e5620 100755 --- a/contrib/checkSpace.pl +++ b/contrib/checkSpace.pl @@ -20,6 +20,10 @@ for $fn (@ARGV) { if (/\t/) { print " TAB:$fn:$.\n"; } + ## Warn about markers that don't have a space in front of them + if (/^[a-zA-Z_][a-zA-Z_0-9]*:/) { + print "nosplabel:$fn:$.\n"; + } ## Warn about trailing whitespace. if (/ +$/) { print "Space\@EOL:$fn:$.\n"; diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 5bb9d70d5d..7bb6103752 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -605,11 +605,11 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt) * after we do so. Use this result to estimate parameters and * calculate the timeout. * - * Returns -1 and sets msg on error. Msg must be freed by the caller. + * Return -1 on error. */ int circuit_build_times_parse_state(circuit_build_times_t *cbt, - or_state_t *state, char **msg) + or_state_t *state) { int tot_values = 0; uint32_t loaded_cnt = 0, N = 0; @@ -617,7 +617,7 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, unsigned int i; build_time_t *loaded_times; circuit_build_times_init(cbt); - *msg = NULL; + int err = 0; if (circuit_build_times_disabled()) { return 0; @@ -631,8 +631,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, smartlist_split_string(args, line->value, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); if (smartlist_len(args) < 2) { - *msg = tor_strdup("Unable to parse circuit build times: " - "Too few arguments to CircuitBuildTime"); + log_warn(LD_GENERAL, "Unable to parse circuit build times: " + "Too few arguments to CircuitBuildTime"); + err = 1; SMARTLIST_FOREACH(args, char*, cp, tor_free(cp)); smartlist_free(args); break; @@ -645,8 +646,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, ms = (build_time_t)tor_parse_ulong(ms_str, 0, 0, CBT_BUILD_TIME_MAX, &ok, NULL); if (!ok) { - *msg = tor_strdup("Unable to parse circuit build times: " - "Unparsable bin number"); + log_warn(LD_GENERAL, "Unable to parse circuit build times: " + "Unparsable bin number"); + err = 1; SMARTLIST_FOREACH(args, char*, cp, tor_free(cp)); smartlist_free(args); break; @@ -654,8 +656,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, count = (uint32_t)tor_parse_ulong(count_str, 0, 0, UINT32_MAX, &ok, NULL); if (!ok) { - *msg = tor_strdup("Unable to parse circuit build times: " - "Unparsable bin count"); + log_warn(LD_GENERAL, "Unable to parse circuit build times: " + "Unparsable bin count"); + err = 1; SMARTLIST_FOREACH(args, char*, cp, tor_free(cp)); smartlist_free(args); break; @@ -692,10 +695,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, "Corrupt state file? Build times count mismatch. " "Read %d times, but file says %d", loaded_cnt, state->TotalBuildTimes); - *msg = tor_strdup("Build times count mismatch."); + err = 1; circuit_build_times_reset(cbt); - tor_free(loaded_times); - return -1; + goto done; } circuit_build_times_shuffle_and_store_array(cbt, loaded_times, loaded_cnt); @@ -716,10 +718,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, "Corrupt state file? Shuffled build times mismatch. " "Read %d times, but file says %d", tot_values, state->TotalBuildTimes); - *msg = tor_strdup("Build times count mismatch."); + err = 1; circuit_build_times_reset(cbt); - tor_free(loaded_times); - return -1; + goto done; } circuit_build_times_set_timeout(cbt); @@ -728,8 +729,9 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt, circuit_build_times_filter_timeouts(cbt); } + done: tor_free(loaded_times); - return *msg ? -1 : 0; + return err ? -1 : 0; } /** @@ -1512,7 +1514,7 @@ static int onion_populate_cpath(origin_circuit_t *circ) { int r; -again: + again: r = onion_extend_cpath(circ); if (r < 0) { log_info(LD_CIRC,"Generating cpath hop failed."); diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h index 3a02f04202..d6aaef2fe9 100644 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@ -81,7 +81,7 @@ extern circuit_build_times_t circ_times; void circuit_build_times_update_state(circuit_build_times_t *cbt, or_state_t *state); int circuit_build_times_parse_state(circuit_build_times_t *cbt, - or_state_t *state, char **msg); + or_state_t *state); void circuit_build_times_count_timeout(circuit_build_times_t *cbt, int did_onehop); int circuit_build_times_count_close(circuit_build_times_t *cbt, diff --git a/src/or/config.c b/src/or/config.c index ef2b2ddeab..e65d1329ce 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -4971,9 +4971,7 @@ or_state_set(or_state_t *new_state) tor_free(err); ret = -1; } - if (circuit_build_times_parse_state(&circ_times, global_state, &err) < 0) { - log_warn(LD_GENERAL,"%s",err); - tor_free(err); + if (circuit_build_times_parse_state(&circ_times, global_state) < 0) { ret = -1; } return ret; diff --git a/src/or/connection.c b/src/or/connection.c index 0eb05b74ab..a16eb37a14 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2353,7 +2353,7 @@ connection_handle_read_impl(connection_t *conn) return 0; } -loop_again: + loop_again: try_to_read = max_to_read; tor_assert(!conn->marked_for_close); diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index e83028faef..64f3429930 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -2050,7 +2050,7 @@ get_unique_stream_id_by_circ(origin_circuit_t *circ) streamid_t test_stream_id; uint32_t attempts=0; -again: + again: test_stream_id = circ->next_stream_id++; if (++attempts > 1<<16) { /* Make sure we don't loop forever if all stream_id's are used. */ @@ -2988,7 +2988,7 @@ parse_extended_hostname(char *address, int allowdotexit) if (rend_valid_service_id(query)) { return ONION_HOSTNAME; /* success */ } -failed: + failed: /* otherwise, return to previous state and return 0 */ *s = '.'; return BAD_HOSTNAME; diff --git a/src/or/control.c b/src/or/control.c index 7cbb1bd1f6..7eead0e18a 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2259,7 +2259,7 @@ handle_control_setcircuitpurpose(control_connection_t *conn, circ->_base.purpose = new_purpose; connection_write_str_to_buf("250 OK\r\n", conn); -done: + done: if (args) { SMARTLIST_FOREACH(args, char *, cp, tor_free(cp)); smartlist_free(args); diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 2760d96665..6f943d78b8 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -192,7 +192,7 @@ connection_cpu_process_inbuf(connection_t *conn) tor_assert(0); /* don't ask me to do handshakes yet */ } -done_processing: + done_processing: conn->state = CPUWORKER_STATE_IDLE; num_cpuworkers_busy--; if (conn->timestamp_created < last_rotation_time) { diff --git a/src/or/dirvote.c b/src/or/dirvote.c index fd4d742ccb..eae3bc8a40 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -762,7 +762,7 @@ networkstatus_check_weights(int64_t Wgg, int64_t Wgd, int64_t Wmg, } } -out: + out: if (berr) { log_info(LD_DIR, "Bw weight mismatch %d. G="I64_FORMAT" M="I64_FORMAT @@ -2942,6 +2942,7 @@ dirvote_compute_consensuses(void) strlen(pending_consensus_signatures), 0); log_notice(LD_DIR, "Signature(s) posted."); + smartlist_free(votes); return 0; err: smartlist_free(votes); @@ -3008,6 +3009,7 @@ dirvote_add_signatures_to_pending_consensus( networkstatus_vote_free(v); } *msg_out = "Signatures added"; + tor_free(new_signatures); } else if (r == 0) { *msg_out = "Signatures ignored"; } else { @@ -3137,7 +3139,7 @@ void dirvote_free_all(void) { dirvote_clear_votes(1); - /* now empty as a result of clear_pending_votes. */ + /* now empty as a result of dirvote_clear_votes(). */ smartlist_free(pending_vote_list); pending_vote_list = NULL; smartlist_free(previous_vote_list); @@ -3146,7 +3148,7 @@ dirvote_free_all(void) dirvote_clear_pending_consensuses(); tor_free(pending_consensus_signatures); if (pending_consensus_signature_list) { - /* now empty as a result of clear_pending_votes. */ + /* now empty as a result of dirvote_clear_votes(). */ smartlist_free(pending_consensus_signature_list); pending_consensus_signature_list = NULL; } diff --git a/src/or/geoip.c b/src/or/geoip.c index cde9cabdb3..d9c8a01519 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -829,7 +829,7 @@ geoip_get_client_history(geoip_client_action_t action) smartlist_add(chunks, buf); }); result = smartlist_join_strings(chunks, ",", 0, NULL); -done: + done: tor_free(counts); if (chunks) { SMARTLIST_FOREACH(chunks, char *, c, tor_free(c)); diff --git a/src/or/policies.c b/src/or/policies.c index db3c6d886b..4fd0904152 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -381,7 +381,7 @@ validate_addr_policies(or_options_t *options, char **msg) ADDR_POLICY_ACCEPT)) REJECT("Error in ReachableDirAddresses entry."); -err: + err: addr_policy_list_free(addr_policy); return *msg ? -1 : 0; #undef REJECT @@ -1272,7 +1272,7 @@ policy_summarize(smartlist_t *policy) result = tor_malloc(final_size); tor_snprintf(result, final_size, "%s %s", prefix, shorter_str); -cleanup: + cleanup: /* cleanup */ SMARTLIST_FOREACH(summary, policy_summary_item_t *, s, tor_free(s)); smartlist_free(summary); diff --git a/src/or/relay.c b/src/or/relay.c index ad3e9afe47..6d0080fad6 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -1327,7 +1327,7 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial) return 0; } -repeat_connection_edge_package_raw_inbuf: + repeat_connection_edge_package_raw_inbuf: circ = circuit_get_by_edge_conn(conn); if (!circ) { diff --git a/src/or/rendclient.c b/src/or/rendclient.c index 0377f121cc..68abb886a8 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -209,7 +209,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc, introcirc->_base.purpose = CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT; return 0; -err: + err: circuit_mark_for_close(TO_CIRCUIT(introcirc), END_CIRC_REASON_INTERNAL); circuit_mark_for_close(TO_CIRCUIT(rendcirc), END_CIRC_REASON_INTERNAL); return -1; diff --git a/src/test/test.c b/src/test/test.c index 2d396b5815..5a37f1da8d 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -485,7 +485,6 @@ test_circuit_timeout(void) circuit_build_times_t final; double timeout1, timeout2; or_state_t state; - char *msg; int i, runs; double close_ms; circuit_build_times_init(&initial); @@ -525,7 +524,7 @@ test_circuit_timeout(void) test_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE); circuit_build_times_update_state(&estimate, &state); - test_assert(circuit_build_times_parse_state(&final, &state, &msg) == 0); + test_assert(circuit_build_times_parse_state(&final, &state) == 0); circuit_build_times_update_alpha(&final); timeout2 = circuit_build_times_calculate_timeout(&final, @@ -627,7 +626,7 @@ test_circuit_timeout(void) circuit_build_times_count_timeout(&final, 1); } -done: + done: return; } diff --git a/src/test/test_dir.c b/src/test/test_dir.c index a129bf9777..80d2379de6 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -580,7 +580,7 @@ test_dir_measured_bw(void) "557365204145532d32353620696e73746561642e") == 0); } -done: + done: return; } |