Commit ac56486b authored by Roger Dingledine's avatar Roger Dingledine
Browse files

use the tor_malloc_zero wrapper


svn:r837
parent ec02f83f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -58,8 +58,7 @@ void circuit_remove(circuit_t *circ) {
circuit_t *circuit_new(circ_id_t p_circ_id, connection_t *p_conn) {
  circuit_t *circ; 

  circ = (circuit_t *)tor_malloc(sizeof(circuit_t));
  memset(circ,0,sizeof(circuit_t)); /* zero it out */
  circ = tor_malloc_zero(sizeof(circuit_t));

  circ->timestamp_created = time(NULL);

+3 −5
Original line number Diff line number Diff line
@@ -76,8 +76,7 @@ connection_t *connection_new(int type) {
  connection_t *conn;
  time_t now = time(NULL);

  conn = (connection_t *)tor_malloc(sizeof(connection_t));
  memset(conn,0,sizeof(connection_t)); /* zero it out to start */
  conn = tor_malloc_zero(sizeof(connection_t));
  conn->s = -1; /* give it a default of 'not used' */

  conn->type = type;
@@ -86,8 +85,7 @@ connection_t *connection_new(int type) {
    conn->outbuf = buf_new();
  }
  if (type == CONN_TYPE_AP) {
    conn->socks_request = tor_malloc(sizeof(socks_request_t));
    memset(conn->socks_request, 0, sizeof(socks_request_t));
    conn->socks_request = tor_malloc_zero(sizeof(socks_request_t));
  }

  conn->timestamp_created = now;
@@ -264,7 +262,7 @@ int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_
  }
  set_socket_nonblocking(s);

  memset((void *)&dest_addr,0,sizeof(dest_addr));
  memset(&dest_addr,0,sizeof(dest_addr));
  dest_addr.sin_family = AF_INET;
  dest_addr.sin_port = htons(port);
  dest_addr.sin_addr.s_addr = htonl(addr);
+2 −1
Original line number Diff line number Diff line
@@ -672,7 +672,8 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
    buf[1] = success ? SOCKS5_SUCCESS : SOCKS5_GENERIC_ERROR;
    buf[2] = 0;
    buf[3] = 1; /* ipv4 addr */
    memset(buf+4,0,6); /* XXX set external addr/port to 0, see what breaks */
    memset(buf+4,0,6); /* Set external addr/port to 0.
                          The spec doesn't seem to say what to do here. -RD */
    connection_write_to_buf(buf,10,conn);
    return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */
  }
+1 −2
Original line number Diff line number Diff line
@@ -340,9 +340,8 @@ list_running_servers(char **nicknames_out)
  for (i = 0; i<n; ++i) {
    length += strlen(nickname_lst[i]);
  }
  *nicknames_out = tor_malloc(length);
  *nicknames_out = tor_malloc_zero(length);
  cp = *nicknames_out;
  memset(cp,0,length);
  for (i = 0; i<n; ++i) {
    if (i)
      strcat(cp, " ");
+1 −2
Original line number Diff line number Diff line
@@ -127,8 +127,7 @@ int dns_resolve(connection_t *exitconn) {
        return -1;
    }
  } else { /* need to add it */
    resolve = tor_malloc(sizeof(struct cached_resolve));
    memset(resolve, 0, sizeof(struct cached_resolve));
    resolve = tor_malloc_zero(sizeof(struct cached_resolve));
    resolve->state = CACHE_STATE_PENDING;
    resolve->expire = now + 15*60; /* 15 minutes */
    strncpy(resolve->question, exitconn->address, MAX_ADDRESSLEN);
Loading