]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Replace a nasty add-malloc-snprintf with a nice clean asprintf
authorNick Mathewson <nickm@torproject.org>
Sun, 15 May 2011 15:41:49 +0000 (11:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Sun, 15 May 2011 15:41:49 +0000 (11:41 -0400)
src/or/circuituse.c

index 86db7c3a02951a797aaf40d164d617288477fd10..7289aa5c119d27c71ff9b2ae56db321207f8100f 100644 (file)
@@ -1513,8 +1513,7 @@ static void
 consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
 {
   or_options_t *options = get_options();
-  size_t len;
-  char *new_address;
+  char *new_address = NULL;
   char fp[HEX_DIGEST_LEN+1];
 
   /* Search the addressmap for this conn's destination. */
@@ -1534,12 +1533,7 @@ consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
                 circ->build_state->chosen_exit->identity_digest, DIGEST_LEN);
 
   /* Add this exit/hostname pair to the addressmap. */
-  len = strlen(conn->socks_request->address) + 1 /* '.' */ +
-        strlen(fp) + 1 /* '.' */ +
-        strlen("exit") + 1 /* '\0' */;
-  new_address = tor_malloc(len);
-
-  tor_snprintf(new_address, len, "%s.%s.exit",
+  tor_asprintf(&new_address, "%s.%s.exit",
                conn->socks_request->address, fp);
 
   addressmap_register(conn->socks_request->address, new_address,