Loading src/common/compat.c +2 −2 Original line number Diff line number Diff line Loading @@ -1687,12 +1687,12 @@ log_credential_status(void) /* log supplementary groups */ sup_gids_size = 64; sup_gids = tor_malloc(sizeof(gid_t) * 64); sup_gids = tor_calloc(sizeof(gid_t), 64); while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 && errno == EINVAL && sup_gids_size < NGROUPS_MAX) { sup_gids_size *= 2; sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size); sup_gids = tor_reallocarray(sup_gids, sizeof(gid_t), sup_gids_size); } if (ngids < 0) { Loading src/common/container.c +3 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ smartlist_new(void) smartlist_t *sl = tor_malloc(sizeof(smartlist_t)); sl->num_used = 0; sl->capacity = SMARTLIST_DEFAULT_CAPACITY; sl->list = tor_malloc(sizeof(void *) * sl->capacity); sl->list = tor_calloc(sizeof(void *), sl->capacity); return sl; } Loading Loading @@ -77,7 +77,8 @@ smartlist_ensure_capacity(smartlist_t *sl, int size) higher *= 2; } sl->capacity = higher; sl->list = tor_realloc(sl->list, sizeof(void*)*((size_t)sl->capacity)); sl->list = tor_reallocarray(sl->list, sizeof(void *), ((size_t)sl->capacity)); } } Loading src/common/container.h +2 −2 Original line number Diff line number Diff line Loading @@ -563,7 +563,7 @@ bitarray_init_zero(unsigned int n_bits) { /* round up to the next int. */ size_t sz = (n_bits+BITARRAY_MASK) >> BITARRAY_SHIFT; return tor_malloc_zero(sz*sizeof(unsigned int)); return tor_calloc(sz, sizeof(unsigned int)); } /** Expand <b>ba</b> from holding <b>n_bits_old</b> to <b>n_bits_new</b>, * clearing all new bits. Returns a possibly changed pointer to the Loading @@ -577,7 +577,7 @@ bitarray_expand(bitarray_t *ba, char *ptr; if (sz_new <= sz_old) return ba; ptr = tor_realloc(ba, sz_new*sizeof(unsigned int)); ptr = tor_reallocarray(ba, sz_new, sizeof(unsigned int)); /* This memset does nothing to the older excess bytes. But they were * already set to 0 by bitarry_init_zero. */ memset(ptr+sz_old*sizeof(unsigned int), 0, Loading src/common/crypto.c +2 −2 Original line number Diff line number Diff line Loading @@ -1838,7 +1838,7 @@ crypto_store_dynamic_dh_modulus(const char *fname) goto done; } base64_encoded_dh = tor_malloc_zero(len * 2); /* should be enough */ base64_encoded_dh = tor_calloc(len, 2); /* should be enough */ new_len = base64_encode(base64_encoded_dh, len * 2, (char *)dh_string_repr, len); if (new_len < 0) { Loading Loading @@ -3164,7 +3164,7 @@ setup_openssl_threading(void) int i; int n = CRYPTO_num_locks(); n_openssl_mutexes_ = n; openssl_mutexes_ = tor_malloc(n*sizeof(tor_mutex_t *)); openssl_mutexes_ = tor_calloc(n, sizeof(tor_mutex_t *)); for (i=0; i < n; ++i) openssl_mutexes_[i] = tor_mutex_new(); CRYPTO_set_locking_callback(openssl_locking_cb_); Loading src/common/util.c +3 −3 Original line number Diff line number Diff line Loading @@ -3392,7 +3392,7 @@ format_win_cmdline_argument(const char *arg) smartlist_add(arg_chars, (void*)&backslash); /* Allocate space for argument, quotes (if needed), and terminator */ formatted_arg = tor_malloc(sizeof(char) * formatted_arg = tor_calloc(sizeof(char), (smartlist_len(arg_chars) + (need_quotes ? 2 : 0) + 1)); /* Add leading quote */ Loading Loading @@ -5022,7 +5022,7 @@ tor_check_port_forwarding(const char *filename, for each smartlist element (one for "-p" and one for the ports), and one for the final NULL. */ args_n = 1 + 2*smartlist_len(ports_to_forward) + 1; argv = tor_malloc_zero(sizeof(char*)*args_n); argv = tor_calloc(sizeof(char *), args_n); argv[argv_index++] = filename; SMARTLIST_FOREACH_BEGIN(ports_to_forward, const char *, port) { Loading Loading
src/common/compat.c +2 −2 Original line number Diff line number Diff line Loading @@ -1687,12 +1687,12 @@ log_credential_status(void) /* log supplementary groups */ sup_gids_size = 64; sup_gids = tor_malloc(sizeof(gid_t) * 64); sup_gids = tor_calloc(sizeof(gid_t), 64); while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 && errno == EINVAL && sup_gids_size < NGROUPS_MAX) { sup_gids_size *= 2; sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size); sup_gids = tor_reallocarray(sup_gids, sizeof(gid_t), sup_gids_size); } if (ngids < 0) { Loading
src/common/container.c +3 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ smartlist_new(void) smartlist_t *sl = tor_malloc(sizeof(smartlist_t)); sl->num_used = 0; sl->capacity = SMARTLIST_DEFAULT_CAPACITY; sl->list = tor_malloc(sizeof(void *) * sl->capacity); sl->list = tor_calloc(sizeof(void *), sl->capacity); return sl; } Loading Loading @@ -77,7 +77,8 @@ smartlist_ensure_capacity(smartlist_t *sl, int size) higher *= 2; } sl->capacity = higher; sl->list = tor_realloc(sl->list, sizeof(void*)*((size_t)sl->capacity)); sl->list = tor_reallocarray(sl->list, sizeof(void *), ((size_t)sl->capacity)); } } Loading
src/common/container.h +2 −2 Original line number Diff line number Diff line Loading @@ -563,7 +563,7 @@ bitarray_init_zero(unsigned int n_bits) { /* round up to the next int. */ size_t sz = (n_bits+BITARRAY_MASK) >> BITARRAY_SHIFT; return tor_malloc_zero(sz*sizeof(unsigned int)); return tor_calloc(sz, sizeof(unsigned int)); } /** Expand <b>ba</b> from holding <b>n_bits_old</b> to <b>n_bits_new</b>, * clearing all new bits. Returns a possibly changed pointer to the Loading @@ -577,7 +577,7 @@ bitarray_expand(bitarray_t *ba, char *ptr; if (sz_new <= sz_old) return ba; ptr = tor_realloc(ba, sz_new*sizeof(unsigned int)); ptr = tor_reallocarray(ba, sz_new, sizeof(unsigned int)); /* This memset does nothing to the older excess bytes. But they were * already set to 0 by bitarry_init_zero. */ memset(ptr+sz_old*sizeof(unsigned int), 0, Loading
src/common/crypto.c +2 −2 Original line number Diff line number Diff line Loading @@ -1838,7 +1838,7 @@ crypto_store_dynamic_dh_modulus(const char *fname) goto done; } base64_encoded_dh = tor_malloc_zero(len * 2); /* should be enough */ base64_encoded_dh = tor_calloc(len, 2); /* should be enough */ new_len = base64_encode(base64_encoded_dh, len * 2, (char *)dh_string_repr, len); if (new_len < 0) { Loading Loading @@ -3164,7 +3164,7 @@ setup_openssl_threading(void) int i; int n = CRYPTO_num_locks(); n_openssl_mutexes_ = n; openssl_mutexes_ = tor_malloc(n*sizeof(tor_mutex_t *)); openssl_mutexes_ = tor_calloc(n, sizeof(tor_mutex_t *)); for (i=0; i < n; ++i) openssl_mutexes_[i] = tor_mutex_new(); CRYPTO_set_locking_callback(openssl_locking_cb_); Loading
src/common/util.c +3 −3 Original line number Diff line number Diff line Loading @@ -3392,7 +3392,7 @@ format_win_cmdline_argument(const char *arg) smartlist_add(arg_chars, (void*)&backslash); /* Allocate space for argument, quotes (if needed), and terminator */ formatted_arg = tor_malloc(sizeof(char) * formatted_arg = tor_calloc(sizeof(char), (smartlist_len(arg_chars) + (need_quotes ? 2 : 0) + 1)); /* Add leading quote */ Loading Loading @@ -5022,7 +5022,7 @@ tor_check_port_forwarding(const char *filename, for each smartlist element (one for "-p" and one for the ports), and one for the final NULL. */ args_n = 1 + 2*smartlist_len(ports_to_forward) + 1; argv = tor_malloc_zero(sizeof(char*)*args_n); argv = tor_calloc(sizeof(char *), args_n); argv[argv_index++] = filename; SMARTLIST_FOREACH_BEGIN(ports_to_forward, const char *, port) { Loading