Commit 136d4e57 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

prefer tor_free to free

plus complain more loudly when we fail to parse a dir we just fetched


svn:r2401
parent 6ed095b1
......@@ -124,7 +124,7 @@ static void circuit_free(circuit_t *circ) {
}
memset(circ, 0xAA, sizeof(circuit_t)); /* poison memory */
free(circ);
tor_free(circ);
}
/** Deallocate space associated with the linked list <b>cpath</b>. */
......@@ -158,7 +158,7 @@ void circuit_free_cpath_node(crypt_path_t *victim) {
crypto_free_digest_env(victim->b_digest);
if(victim->handshake_state)
crypto_dh_free(victim->handshake_state);
free(victim);
tor_free(victim);
}
/** Return a circ such that:
......
......@@ -114,9 +114,9 @@ static void config_free_lines(struct config_line_t *front) {
tmp = front;
front = tmp->next;
free(tmp->key);
free(tmp->value);
free(tmp);
tor_free(tmp->key);
tor_free(tmp->value);
tor_free(tmp);
}
}
......
......@@ -158,7 +158,7 @@ void connection_free(connection_t *conn) {
tor_close_socket(conn->s);
}
memset(conn, 0xAA, sizeof(connection_t)); /* poison memory */
free(conn);
tor_free(conn);
}
/** Call connection_free() on every connection in our array.
......
......@@ -400,7 +400,7 @@ connection_dir_client_reached_eof(connection_t *conn)
if(parse_http_response(headers, &status_code, NULL, &date_header,
&compression) < 0) {
log_fn(LOG_WARN,"Unparseable headers. Closing.");
free(body); free(headers);
tor_free(body); tor_free(headers);
return -1;
}
if (date_header > 0) {
......@@ -433,17 +433,17 @@ connection_dir_client_reached_eof(connection_t *conn)
log_fn(LOG_INFO,"Received directory (size %d):\n%s", body_len, body);
if(status_code == 503 || body_len == 0) {
log_fn(LOG_INFO,"Empty directory. Ignoring.");
free(body); free(headers);
tor_free(body); tor_free(headers);
return 0;
}
if(status_code != 200) {
log_fn(LOG_WARN,"Received http status code %d from dirserver. Failing.",
status_code);
free(body); free(headers);
tor_free(body); tor_free(headers);
return -1;
}
if(router_load_routerlist_from_directory(body, NULL) < 0){
log_fn(LOG_INFO,"...but parsing failed. Ignoring.");
log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
} else {
log_fn(LOG_INFO,"updated routers.");
}
......@@ -458,12 +458,12 @@ connection_dir_client_reached_eof(connection_t *conn)
if(status_code != 200) {
log_fn(LOG_WARN,"Received http status code %d from dirserver. Failing.",
status_code);
free(body); free(headers);
tor_free(body); tor_free(headers);
return -1;
}
if (!(rrs = router_parse_runningrouters(body))) {
log_fn(LOG_WARN, "Can't parse runningrouters list");
free(body); free(headers);
tor_free(body); tor_free(headers);
return -1;
}
router_get_routerlist(&rl);
......@@ -526,7 +526,7 @@ connection_dir_client_reached_eof(connection_t *conn)
break;
}
}
free(body); free(headers);
tor_free(body); tor_free(headers);
return 0;
}
......
......@@ -275,7 +275,7 @@ static void free_descriptor_entry(descriptor_entry_t *desc)
tor_free(desc->descriptor);
tor_free(desc->nickname);
routerinfo_free(desc->router);
free(desc);
tor_free(desc);
}
/** Release all storage that the dirserv is holding for server
......@@ -594,7 +594,7 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
"running-routers %s\n\n",
published, options.RecommendedVersions, cp);
free(cp);
tor_free(cp);
i = strlen(s);
cp = s+i;
......@@ -749,7 +749,7 @@ static int dirserv_regenerate_directory(void)
tor_cleanup();
exit(0);
}
free(new_directory);
tor_free(new_directory);
if(get_data_directory(&options)) {
snprintf(filename,sizeof(filename),"%s/cached-directory", get_data_directory(&options));
if(write_str_to_file(filename,the_directory,0) < 0) {
......
......@@ -297,7 +297,6 @@ static void conn_write(int i) {
static void conn_close_if_marked(int i) {
connection_t *conn;
int retval;
struct in_addr in;
conn = connection_array[i];
assert_connection_ok(conn, time(NULL));
......@@ -309,12 +308,11 @@ static void conn_close_if_marked(int i) {
if(conn->s >= 0 && connection_wants_to_flush(conn)) {
/* -1 means it's an incomplete edge connection, or that the socket
* has already been closed as unflushable. */
in.s_addr = htonl(conn->addr);
if(!conn->hold_open_until_flushed)
log_fn(LOG_INFO,
"Conn (addr %s, fd %d, type %s, state %d) marked, but wants to flush %d bytes. "
"(Marked at %s:%d)",
inet_ntoa(in), conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
conn->address, conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
conn->outbuf_flushlen, conn->marked_for_close_file, conn->marked_for_close);
if(connection_speaks_cells(conn)) {
if(conn->state == OR_CONN_STATE_OPEN) {
......@@ -332,7 +330,7 @@ static void conn_close_if_marked(int i) {
}
if(connection_wants_to_flush(conn)) {
log_fn(LOG_WARN,"Conn (addr %s, fd %d, type %s, state %d) still wants to flush. Losing %d bytes! (Marked at %s:%d)",
inet_ntoa(in), conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
conn->address, conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
(int)buf_datalen(conn->outbuf), conn->marked_for_close_file,
conn->marked_for_close);
}
......
......@@ -47,7 +47,7 @@ int onion_pending_add(circuit_t *circ) {
if(ol_length >= options.MaxOnionsPending) {
log_fn(LOG_WARN,"Already have %d onions queued. Closing.", ol_length);
free(tmp);
tor_free(tmp);
return -1;
}
......@@ -109,7 +109,7 @@ void onion_pending_remove(circuit_t *circ) {
/* now victim points to the element that needs to be removed */
free(victim);
tor_free(victim);
}
/*----------------------------------------------------------------------*/
......
......@@ -767,7 +767,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
s);
return -1;
}
free(s_dup);
tor_free(s_dup);
routerinfo_free(ri_tmp);
#endif
......
......@@ -540,7 +540,7 @@ void routerinfo_free(routerinfo_t *router)
if (router->identity_pkey)
crypto_free_pk_env(router->identity_pkey);
exit_policy_free(router->exit_policy);
free(router);
tor_free(router);
}
/** Allocate a fresh copy of <b>router</b> */
......@@ -717,12 +717,12 @@ int router_load_routerlist_from_file(char *routerfile, int trusted)
if(router_load_routerlist_from_string(string, trusted) < 0) {
log_fn(LOG_WARN,"The routerfile itself was corrupt.");
free(string);
tor_free(string);
return -1;
}
/* dump_onion_keys(LOG_NOTICE); */
free(string);
tor_free(string);
return 0;
}
......
......@@ -872,7 +872,7 @@ router_parse_exit_policy_from_string(const char *s)
err:
r = NULL;
done:
free(tmp);
tor_free(tmp);
token_free(tok);
return r;
}
......@@ -1009,7 +1009,7 @@ policy_read_failed:
tor_assert(newe->string);
log_fn(LOG_WARN,"Couldn't parse line '%s'. Dropping", newe->string);
tor_free(newe->string);
free(newe);
tor_free(newe);
return NULL;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment