From 41640b65735ec6214aa5080c2143b0982a59bb93 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 10 Jul 2018 15:16:57 -0400 Subject: Rename util_malloc to malloc. --- src/lib/compress/compress.c | 2 +- src/lib/compress/compress_lzma.c | 2 +- src/lib/container/bitarray.h | 2 +- src/lib/container/bloomfilt.c | 2 +- src/lib/container/buffers.c | 2 +- src/lib/container/handles.h | 2 +- src/lib/container/map.c | 2 +- src/lib/container/smartlist.c | 2 +- src/lib/crypt_ops/aes.h | 2 +- src/lib/crypt_ops/crypto_digest.h | 2 +- src/lib/crypt_ops/crypto_rand.c | 2 +- src/lib/ctime/di_ops.c | 2 +- src/lib/encoding/binascii.c | 2 +- src/lib/encoding/confline.c | 2 +- src/lib/encoding/cstring.c | 2 +- src/lib/encoding/time_fmt.c | 2 +- src/lib/evloop/compat_libevent.h | 2 +- src/lib/evloop/procmon.c | 2 +- src/lib/evloop/timers.c | 2 +- src/lib/fs/conffile.c | 2 +- src/lib/fs/dir.c | 2 +- src/lib/fs/files.c | 2 +- src/lib/fs/lockfile.c | 2 +- src/lib/fs/mmap.c | 2 +- src/lib/fs/path.c | 2 +- src/lib/fs/storagedir.c | 2 +- src/lib/fs/userdb.c | 2 +- src/lib/lock/compat_mutex.c | 2 +- src/lib/lock/compat_mutex.h | 2 +- src/lib/log/escape.c | 2 +- src/lib/log/ratelim.c | 2 +- src/lib/log/torlog.c | 2 +- src/lib/log/util_bug.c | 2 +- src/lib/log/win32err.c | 2 +- src/lib/malloc/include.am | 4 +- src/lib/malloc/malloc.c | 230 +++++++++++++++++++++++++++++++ src/lib/malloc/malloc.h | 92 +++++++++++++ src/lib/malloc/util_malloc.c | 230 ------------------------------- src/lib/malloc/util_malloc.h | 92 ------------- src/lib/memarea/memarea.c | 2 +- src/lib/meminfo/meminfo.c | 2 +- src/lib/net/address.c | 2 +- src/lib/net/resolve.c | 2 +- src/lib/process/env.c | 4 +- src/lib/process/setuid.c | 2 +- src/lib/process/subprocess.c | 2 +- src/lib/process/waitpid.c | 2 +- src/lib/sandbox/sandbox.c | 2 +- src/lib/smartlist_core/smartlist_core.c | 2 +- src/lib/smartlist_core/smartlist_split.c | 2 +- src/lib/string/printf.c | 2 +- src/lib/term/getpass.c | 2 +- 52 files changed, 372 insertions(+), 372 deletions(-) create mode 100644 src/lib/malloc/malloc.c create mode 100644 src/lib/malloc/malloc.h delete mode 100644 src/lib/malloc/util_malloc.c delete mode 100644 src/lib/malloc/util_malloc.h (limited to 'src/lib') diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c index e87e788f14..ff1aea47a4 100644 --- a/src/lib/compress/compress.c +++ b/src/lib/compress/compress.c @@ -32,7 +32,7 @@ #include "lib/compress/compress_zlib.h" #include "lib/compress/compress_zstd.h" #include "lib/intmath/cmp.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/thread/threads.h" /** Total number of bytes allocated for compression state overhead. */ diff --git a/src/lib/compress/compress_lzma.c b/src/lib/compress/compress_lzma.c index 3b6f91b84b..9091832ed3 100644 --- a/src/lib/compress/compress_lzma.c +++ b/src/lib/compress/compress_lzma.c @@ -17,7 +17,7 @@ #include "lib/compress/compress_lzma.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/thread/threads.h" #ifdef HAVE_LZMA diff --git a/src/lib/container/bitarray.h b/src/lib/container/bitarray.h index 172d56cc06..ae82a4ab4d 100644 --- a/src/lib/container/bitarray.h +++ b/src/lib/container/bitarray.h @@ -15,7 +15,7 @@ #include "orconfig.h" #include #include "lib/cc/torint.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #if SIZEOF_INT == 4 #define BITARRAY_SHIFT 5 diff --git a/src/lib/container/bloomfilt.c b/src/lib/container/bloomfilt.c index 1cab817e18..ea2d2917c7 100644 --- a/src/lib/container/bloomfilt.c +++ b/src/lib/container/bloomfilt.c @@ -10,7 +10,7 @@ #include -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/container/bloomfilt.h" #include "lib/intmath/bits.h" #include "lib/log/util_bug.h" diff --git a/src/lib/container/buffers.c b/src/lib/container/buffers.c index 5849704e35..525747a4c9 100644 --- a/src/lib/container/buffers.c +++ b/src/lib/container/buffers.c @@ -30,7 +30,7 @@ #include "lib/log/torlog.h" #include "lib/log/util_bug.h" #include "lib/ctime/di_ops.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" #include "lib/time/compat_time.h" diff --git a/src/lib/container/handles.h b/src/lib/container/handles.h index 21ec0dfeec..7144e1720d 100644 --- a/src/lib/container/handles.h +++ b/src/lib/container/handles.h @@ -52,7 +52,7 @@ #include "orconfig.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #define HANDLE_ENTRY(name, structname) \ struct name ## _handle_head_t *handle_head diff --git a/src/lib/container/map.c b/src/lib/container/map.c index 0602eac891..85e074e10a 100644 --- a/src/lib/container/map.c +++ b/src/lib/container/map.c @@ -14,7 +14,7 @@ #include "lib/ctime/di_ops.h" #include "lib/defs/digest_sizes.h" #include "lib/string/util_string.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/log/util_bug.h" diff --git a/src/lib/container/smartlist.c b/src/lib/container/smartlist.c index c3abbff513..dc283e5f50 100644 --- a/src/lib/container/smartlist.c +++ b/src/lib/container/smartlist.c @@ -17,7 +17,7 @@ #include "lib/container/smartlist.h" #include "lib/err/torerr.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/defs/digest_sizes.h" #include "lib/ctime/di_ops.h" #include "lib/string/compat_ctype.h" diff --git a/src/lib/crypt_ops/aes.h b/src/lib/crypt_ops/aes.h index a57654159a..578a1a65a2 100644 --- a/src/lib/crypt_ops/aes.h +++ b/src/lib/crypt_ops/aes.h @@ -14,7 +14,7 @@ */ #include "lib/cc/torint.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" typedef struct aes_cnt_cipher aes_cnt_cipher_t; diff --git a/src/lib/crypt_ops/crypto_digest.h b/src/lib/crypt_ops/crypto_digest.h index 15bc5ad5b9..9facf3b981 100644 --- a/src/lib/crypt_ops/crypto_digest.h +++ b/src/lib/crypt_ops/crypto_digest.h @@ -15,7 +15,7 @@ #include "lib/cc/torint.h" #include "lib/defs/digest_sizes.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" /** Length of a sha1 message digest when encoded in base32 with trailing = * signs removed. */ diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c index 6f479b013b..e2d72a77c0 100644 --- a/src/lib/crypt_ops/crypto_rand.c +++ b/src/lib/crypt_ops/crypto_rand.c @@ -28,7 +28,7 @@ #include "lib/intmath/weakrng.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/sandbox/sandbox.h" #include "lib/string/compat_string.h" #include "lib/string/util_string.h" diff --git a/src/lib/ctime/di_ops.c b/src/lib/ctime/di_ops.c index 287ff6080a..011baf2654 100644 --- a/src/lib/ctime/di_ops.c +++ b/src/lib/ctime/di_ops.c @@ -9,7 +9,7 @@ #include "orconfig.h" #include "lib/ctime/di_ops.h" #include "lib/err/torerr.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include diff --git a/src/lib/encoding/binascii.c b/src/lib/encoding/binascii.c index df9bb4a813..7499d64720 100644 --- a/src/lib/encoding/binascii.c +++ b/src/lib/encoding/binascii.c @@ -19,7 +19,7 @@ #include "lib/cc/torint.h" #include "lib/string/compat_ctype.h" #include "lib/intmath/muldiv.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include #include diff --git a/src/lib/encoding/confline.c b/src/lib/encoding/confline.c index 3486b6a82b..9b17629537 100644 --- a/src/lib/encoding/confline.c +++ b/src/lib/encoding/confline.c @@ -19,7 +19,7 @@ #include "lib/encoding/cstring.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/compat_ctype.h" #include "lib/string/compat_string.h" #include "lib/string/util_string.h" diff --git a/src/lib/encoding/cstring.c b/src/lib/encoding/cstring.c index 994a52e70c..3e0db712f9 100644 --- a/src/lib/encoding/cstring.c +++ b/src/lib/encoding/cstring.c @@ -13,7 +13,7 @@ #include "lib/encoding/cstring.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/compat_ctype.h" #include diff --git a/src/lib/encoding/time_fmt.c b/src/lib/encoding/time_fmt.c index c2ff34a91a..8ce15e7477 100644 --- a/src/lib/encoding/time_fmt.c +++ b/src/lib/encoding/time_fmt.c @@ -18,7 +18,7 @@ #include "lib/log/torlog.h" #include "lib/log/escape.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" #include "lib/string/scanf.h" #include "lib/wallclock/tm_cvt.h" diff --git a/src/lib/evloop/compat_libevent.h b/src/lib/evloop/compat_libevent.h index 7a5469047c..5fda49f741 100644 --- a/src/lib/evloop/compat_libevent.h +++ b/src/lib/evloop/compat_libevent.h @@ -11,7 +11,7 @@ #include "orconfig.h" #include "lib/testsupport/testsupport.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" void configure_libevent_logging(void); void suppress_libevent_log_msg(const char *msg); diff --git a/src/lib/evloop/procmon.c b/src/lib/evloop/procmon.c index a923fbad74..53c458f159 100644 --- a/src/lib/evloop/procmon.c +++ b/src/lib/evloop/procmon.c @@ -11,7 +11,7 @@ #include "lib/log/torlog.h" #include "lib/log/util_bug.h" #include "lib/log/win32err.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/parse_int.h" #ifdef HAVE_SIGNAL_H diff --git a/src/lib/evloop/timers.c b/src/lib/evloop/timers.c index c07bd2e726..4580b89e3c 100644 --- a/src/lib/evloop/timers.c +++ b/src/lib/evloop/timers.c @@ -36,7 +36,7 @@ #include "lib/intmath/muldiv.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/time/compat_time.h" #ifdef _WIN32 diff --git a/src/lib/fs/conffile.c b/src/lib/fs/conffile.c index 600c7f6b70..3a4d95f450 100644 --- a/src/lib/fs/conffile.c +++ b/src/lib/fs/conffile.c @@ -18,7 +18,7 @@ #include "lib/fs/files.h" #include "lib/fs/path.h" #include "lib/log/torlog.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" static smartlist_t *config_get_file_list(const char *path, diff --git a/src/lib/fs/dir.c b/src/lib/fs/dir.c index cc339f747e..0f2a5e2359 100644 --- a/src/lib/fs/dir.c +++ b/src/lib/fs/dir.c @@ -19,7 +19,7 @@ #include "lib/log/win32err.h" #include "lib/container/smartlist.h" #include "lib/sandbox/sandbox.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" #include "lib/string/compat_string.h" diff --git a/src/lib/fs/files.c b/src/lib/fs/files.c index 4e0a398baa..9012fd64f2 100644 --- a/src/lib/fs/files.c +++ b/src/lib/fs/files.c @@ -20,7 +20,7 @@ #include "lib/log/util_bug.h" #include "lib/log/escape.h" #include "lib/err/torerr.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/sandbox/sandbox.h" #include "lib/string/printf.h" #include "lib/string/util_string.h" diff --git a/src/lib/fs/lockfile.c b/src/lib/fs/lockfile.c index 972fd5658d..a4e3c427db 100644 --- a/src/lib/fs/lockfile.c +++ b/src/lib/fs/lockfile.c @@ -15,7 +15,7 @@ #include "lib/fs/lockfile.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef HAVE_SYS_FILE_H #include diff --git a/src/lib/fs/mmap.c b/src/lib/fs/mmap.c index 2d758c1b5f..7d91945bb9 100644 --- a/src/lib/fs/mmap.c +++ b/src/lib/fs/mmap.c @@ -15,7 +15,7 @@ #include "lib/log/util_bug.h" #include "lib/log/win32err.h" #include "lib/string/compat_string.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef HAVE_MMAP #include diff --git a/src/lib/fs/path.c b/src/lib/fs/path.c index 708ff0505a..9b32b2ebd3 100644 --- a/src/lib/fs/path.c +++ b/src/lib/fs/path.c @@ -10,7 +10,7 @@ **/ #include "lib/fs/path.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" #include "lib/string/printf.h" diff --git a/src/lib/fs/storagedir.c b/src/lib/fs/storagedir.c index 1cda2374d8..4db56b02f8 100644 --- a/src/lib/fs/storagedir.c +++ b/src/lib/fs/storagedir.c @@ -22,7 +22,7 @@ #include "lib/log/escape.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/memarea/memarea.h" #include "lib/sandbox/sandbox.h" #include "lib/string/printf.h" diff --git a/src/lib/fs/userdb.c b/src/lib/fs/userdb.c index 3d7a9da59d..1e772b8fbd 100644 --- a/src/lib/fs/userdb.c +++ b/src/lib/fs/userdb.c @@ -12,7 +12,7 @@ #include "lib/fs/userdb.h" #ifndef _WIN32 -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" diff --git a/src/lib/lock/compat_mutex.c b/src/lib/lock/compat_mutex.c index bfab6dd29b..b53676cf49 100644 --- a/src/lib/lock/compat_mutex.c +++ b/src/lib/lock/compat_mutex.c @@ -10,7 +10,7 @@ **/ #include "lib/lock/compat_mutex.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" /** Return a newly allocated, ready-for-use mutex. */ tor_mutex_t * diff --git a/src/lib/lock/compat_mutex.h b/src/lib/lock/compat_mutex.h index f467aa5dba..f8689422b1 100644 --- a/src/lib/lock/compat_mutex.h +++ b/src/lib/lock/compat_mutex.h @@ -14,7 +14,7 @@ #include "orconfig.h" #include "lib/cc/torint.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #if defined(HAVE_PTHREAD_H) && !defined(_WIN32) #include diff --git a/src/lib/log/escape.c b/src/lib/log/escape.c index b6b20183ba..37d7e0fdc4 100644 --- a/src/lib/log/escape.c +++ b/src/lib/log/escape.c @@ -12,7 +12,7 @@ #include "lib/log/util_bug.h" #include "lib/string/compat_ctype.h" #include "lib/string/printf.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" /** Allocate and return a new string representing the contents of s, * surrounded by quotes and using standard C escapes. diff --git a/src/lib/log/ratelim.c b/src/lib/log/ratelim.c index fba702d7f0..2d0e8b17ca 100644 --- a/src/lib/log/ratelim.c +++ b/src/lib/log/ratelim.c @@ -9,7 +9,7 @@ **/ #include "lib/log/ratelim.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" /** If the rate-limiter lim is ready at now, return the number diff --git a/src/lib/log/torlog.c b/src/lib/log/torlog.c index 1c9f33790d..46d1217554 100644 --- a/src/lib/log/torlog.c +++ b/src/lib/log/torlog.c @@ -41,7 +41,7 @@ #include "lib/intmath/bits.h" #include "lib/string/compat_string.h" #include "lib/string/printf.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/util_string.h" #include "lib/wallclock/tor_gettimeofday.h" #include "lib/wallclock/approx_time.h" diff --git a/src/lib/log/util_bug.c b/src/lib/log/util_bug.c index 78af08f022..e3c8df0d64 100644 --- a/src/lib/log/util_bug.c +++ b/src/lib/log/util_bug.c @@ -15,7 +15,7 @@ #include "lib/smartlist_core/smartlist_core.h" #include "lib/smartlist_core/smartlist_foreach.h" #endif -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/printf.h" #include diff --git a/src/lib/log/win32err.c b/src/lib/log/win32err.c index 6603ed4648..41f563bfa5 100644 --- a/src/lib/log/win32err.c +++ b/src/lib/log/win32err.c @@ -11,7 +11,7 @@ #ifdef _WIN32 #include "orconfig.h" #include "lib/log/win32err.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include #include diff --git a/src/lib/malloc/include.am b/src/lib/malloc/include.am index 50de9cb736..502cc1c6b7 100644 --- a/src/lib/malloc/include.am +++ b/src/lib/malloc/include.am @@ -6,7 +6,7 @@ noinst_LIBRARIES += src/lib/libtor-malloc-testing.a endif src_lib_libtor_malloc_a_SOURCES = \ - src/lib/malloc/util_malloc.c + src/lib/malloc/malloc.c if USE_OPENBSD_MALLOC src_lib_libtor_malloc_a_SOURCES += src/ext/OpenBSD_malloc_Linux.c @@ -18,4 +18,4 @@ src_lib_libtor_malloc_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_lib_libtor_malloc_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) noinst_HEADERS += \ - src/lib/malloc/util_malloc.h + src/lib/malloc/malloc.h diff --git a/src/lib/malloc/malloc.c b/src/lib/malloc/malloc.c new file mode 100644 index 0000000000..271e84071a --- /dev/null +++ b/src/lib/malloc/malloc.c @@ -0,0 +1,230 @@ +/* Copyright (c) 2003, Roger Dingledine + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file malloc.c + * \brief Wrappers for C malloc code, and replacements for items that + * may be missing. + **/ + +#include "orconfig.h" + +#include +#include + +#include "lib/testsupport/testsupport.h" +#define UTIL_MALLOC_PRIVATE +#include "lib/malloc/malloc.h" +#include "lib/cc/torint.h" +#include "lib/err/torerr.h" + +#ifdef __clang_analyzer__ +#undef MALLOC_ZERO_WORKS +#endif + +/** Allocate a chunk of size bytes of memory, and return a pointer to + * result. On error, log and terminate the process. (Same as malloc(size), + * but never returns NULL.) + */ +void * +tor_malloc_(size_t size) +{ + void *result; + + raw_assert(size < SIZE_T_CEILING); + +#ifndef MALLOC_ZERO_WORKS + /* Some libc mallocs don't work when size==0. Override them. */ + if (size==0) { + size=1; + } +#endif /* !defined(MALLOC_ZERO_WORKS) */ + + result = raw_malloc(size); + + if (PREDICT_UNLIKELY(result == NULL)) { + /* LCOV_EXCL_START */ + /* If these functions die within a worker process, they won't call + * spawn_exit, but that's ok, since the parent will run out of memory soon + * anyway. */ + raw_assert_unreached_msg("Out of memory on malloc(). Dying."); + /* LCOV_EXCL_STOP */ + } + return result; +} + +/** Allocate a chunk of size bytes of memory, fill the memory with + * zero bytes, and return a pointer to the result. Log and terminate + * the process on error. (Same as calloc(size,1), but never returns NULL.) + */ +void * +tor_malloc_zero_(size_t size) +{ + /* You may ask yourself, "wouldn't it be smart to use calloc instead of + * malloc+memset? Perhaps libc's calloc knows some nifty optimization trick + * we don't!" Indeed it does, but its optimizations are only a big win when + * we're allocating something very big (it knows if it just got the memory + * from the OS in a pre-zeroed state). We don't want to use tor_malloc_zero + * for big stuff, so we don't bother with calloc. */ + void *result = tor_malloc_(size); + memset(result, 0, size); + return result; +} + +/* The square root of SIZE_MAX + 1. If a is less than this, and b is less + * than this, then a*b is less than SIZE_MAX. (For example, if size_t is + * 32 bits, then SIZE_MAX is 0xffffffff and this value is 0x10000. If a and + * b are less than this, then their product is at most (65535*65535) == + * 0xfffe0001. */ +#define SQRT_SIZE_MAX_P1 (((size_t)1) << (sizeof(size_t)*4)) + +/** Return non-zero if and only if the product of the arguments is exact, + * and cannot overflow. */ +STATIC int +size_mul_check(const size_t x, const size_t y) +{ + /* This first check is equivalent to + (x < SQRT_SIZE_MAX_P1 && y < SQRT_SIZE_MAX_P1) + + Rationale: if either one of x or y is >= SQRT_SIZE_MAX_P1, then it + will have some bit set in its most significant half. + */ + return ((x|y) < SQRT_SIZE_MAX_P1 || + y == 0 || + x <= SIZE_MAX / y); +} + +/** Allocate a chunk of nmemb*size bytes of memory, fill + * the memory with zero bytes, and return a pointer to the result. + * Log and terminate the process on error. (Same as + * calloc(nmemb,size), but never returns NULL.) + * The second argument (size) should preferably be non-zero + * and a compile-time constant. + */ +void * +tor_calloc_(size_t nmemb, size_t size) +{ + raw_assert(size_mul_check(nmemb, size)); + return tor_malloc_zero_((nmemb * size)); +} + +/** Change the size of the memory block pointed to by ptr to size + * bytes long; return the new memory block. On error, log and + * terminate. (Like realloc(ptr,size), but never returns NULL.) + */ +void * +tor_realloc_(void *ptr, size_t size) +{ + void *result; + + raw_assert(size < SIZE_T_CEILING); + +#ifndef MALLOC_ZERO_WORKS + /* Some libc mallocs don't work when size==0. Override them. */ + if (size==0) { + size=1; + } +#endif /* !defined(MALLOC_ZERO_WORKS) */ + + result = raw_realloc(ptr, size); + + if (PREDICT_UNLIKELY(result == NULL)) { + /* LCOV_EXCL_START */ + raw_assert_unreached_msg("Out of memory on realloc(). Dying."); + /* LCOV_EXCL_STOP */ + } + return result; +} + +/** + * Try to realloc ptr so that it takes up sz1 * sz2 bytes. Check for + * overflow. Unlike other allocation functions, return NULL on overflow. + */ +void * +tor_reallocarray_(void *ptr, size_t sz1, size_t sz2) +{ + /* XXXX we can make this return 0, but we would need to check all the + * reallocarray users. */ + raw_assert(size_mul_check(sz1, sz2)); + + return tor_realloc(ptr, (sz1 * sz2)); +} + +/** Return a newly allocated copy of the NUL-terminated string s. On + * error, log and terminate. (Like strdup(s), but never returns + * NULL.) + */ +char * +tor_strdup_(const char *s) +{ + char *duplicate; + raw_assert(s); + + duplicate = raw_strdup(s); + + if (PREDICT_UNLIKELY(duplicate == NULL)) { + /* LCOV_EXCL_START */ + raw_assert_unreached_msg("Out of memory on strdup(). Dying."); + /* LCOV_EXCL_STOP */ + } + return duplicate; +} + +/** Allocate and return a new string containing the first n + * characters of s. If s is longer than n + * characters, only the first n are copied. The result is + * always NUL-terminated. (Like strndup(s,n), but never returns + * NULL.) + */ +char * +tor_strndup_(const char *s, size_t n) +{ + char *duplicate; + raw_assert(s); + raw_assert(n < SIZE_T_CEILING); + duplicate = tor_malloc_((n+1)); + /* Performance note: Ordinarily we prefer strlcpy to strncpy. But + * this function gets called a whole lot, and platform strncpy is + * much faster than strlcpy when strlen(s) is much longer than n. + */ + strncpy(duplicate, s, n); + duplicate[n]='\0'; + return duplicate; +} + +/** Allocate a chunk of len bytes, with the same contents as the + * len bytes starting at mem. */ +void * +tor_memdup_(const void *mem, size_t len) +{ + char *duplicate; + raw_assert(len < SIZE_T_CEILING); + raw_assert(mem); + duplicate = tor_malloc_(len); + memcpy(duplicate, mem, len); + return duplicate; +} + +/** As tor_memdup(), but add an extra 0 byte at the end of the resulting + * memory. */ +void * +tor_memdup_nulterm_(const void *mem, size_t len) +{ + char *duplicate; + raw_assert(len < SIZE_T_CEILING+1); + raw_assert(mem); + duplicate = tor_malloc_(len+1); + memcpy(duplicate, mem, len); + duplicate[len] = '\0'; + return duplicate; +} + +/** Helper for places that need to take a function pointer to the right + * spelling of "free()". */ +void +tor_free_(void *mem) +{ + tor_free(mem); +} diff --git a/src/lib/malloc/malloc.h b/src/lib/malloc/malloc.h new file mode 100644 index 0000000000..26ee30742e --- /dev/null +++ b/src/lib/malloc/malloc.h @@ -0,0 +1,92 @@ +/* Copyright (c) 2003-2004, Roger Dingledine + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file malloc.h + * \brief Headers for util_malloc.c + **/ + +#ifndef TOR_UTIL_MALLOC_H +#define TOR_UTIL_MALLOC_H + +#include +#include +#include "lib/cc/compat_compiler.h" + +/* Memory management */ +void *tor_malloc_(size_t size) ATTR_MALLOC; +void *tor_malloc_zero_(size_t size) ATTR_MALLOC; +void *tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC; +void *tor_realloc_(void *ptr, size_t size); +void *tor_reallocarray_(void *ptr, size_t size1, size_t size2); +char *tor_strdup_(const char *s) ATTR_MALLOC; +char *tor_strndup_(const char *s, size_t n) + ATTR_MALLOC; +void *tor_memdup_(const void *mem, size_t len) + ATTR_MALLOC; +void *tor_memdup_nulterm_(const void *mem, size_t len) + ATTR_MALLOC; +void tor_free_(void *mem); + +/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, + * etc. Unlike the free() function, the tor_free() macro sets the + * pointer value to NULL after freeing it. + * + * This is a macro. If you need a function pointer to release memory from + * tor_malloc(), use tor_free_(). + * + * Note that this macro takes the address of the pointer it is going to + * free and clear. If that pointer is stored with a nonstandard + * alignment (eg because of a "packed" pragma) it is not correct to use + * tor_free(). + */ +#ifdef __GNUC__ +#define tor_free(p) STMT_BEGIN \ + typeof(&(p)) tor_free__tmpvar = &(p); \ + raw_free(*tor_free__tmpvar); \ + *tor_free__tmpvar=NULL; \ + STMT_END +#else +#define tor_free(p) STMT_BEGIN \ + raw_free(p); \ + (p)=NULL; \ + STMT_END +#endif + +#define tor_malloc(size) tor_malloc_(size) +#define tor_malloc_zero(size) tor_malloc_zero_(size) +#define tor_calloc(nmemb,size) tor_calloc_(nmemb, size) +#define tor_realloc(ptr, size) tor_realloc_(ptr, size) +#define tor_reallocarray(ptr, sz1, sz2) \ + tor_reallocarray_((ptr), (sz1), (sz2)) +#define tor_strdup(s) tor_strdup_(s) +#define tor_strndup(s, n) tor_strndup_(s, n) +#define tor_memdup(s, n) tor_memdup_(s, n) +#define tor_memdup_nulterm(s, n) tor_memdup_nulterm_(s, n) + +/* Aliases for the underlying system malloc/realloc/free. Only use + * them to indicate "I really want the underlying system function, I know + * what I'm doing." */ +#define raw_malloc malloc +#define raw_realloc realloc +#define raw_free free +#define raw_strdup strdup + +/* Helper macro: free a variable of type 'typename' using freefn, and + * set the variable to NULL. + */ +#define FREE_AND_NULL(typename, freefn, var) \ + do { \ + /* only evaluate (var) once. */ \ + typename **tmp__free__ptr ## freefn = &(var); \ + freefn(*tmp__free__ptr ## freefn); \ + (*tmp__free__ptr ## freefn) = NULL; \ + } while (0) + +#ifdef UTIL_MALLOC_PRIVATE +STATIC int size_mul_check(const size_t x, const size_t y); +#endif + +#endif /* !defined(TOR_UTIL_MALLOC_H) */ diff --git a/src/lib/malloc/util_malloc.c b/src/lib/malloc/util_malloc.c deleted file mode 100644 index f3b0e50c70..0000000000 --- a/src/lib/malloc/util_malloc.c +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright (c) 2003, Roger Dingledine - * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2018, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file util_malloc.c - * \brief Wrappers for C malloc code, and replacements for items that - * may be missing. - **/ - -#include "orconfig.h" - -#include -#include - -#include "lib/testsupport/testsupport.h" -#define UTIL_MALLOC_PRIVATE -#include "lib/malloc/util_malloc.h" -#include "lib/cc/torint.h" -#include "lib/err/torerr.h" - -#ifdef __clang_analyzer__ -#undef MALLOC_ZERO_WORKS -#endif - -/** Allocate a chunk of size bytes of memory, and return a pointer to - * result. On error, log and terminate the process. (Same as malloc(size), - * but never returns NULL.) - */ -void * -tor_malloc_(size_t size) -{ - void *result; - - raw_assert(size < SIZE_T_CEILING); - -#ifndef MALLOC_ZERO_WORKS - /* Some libc mallocs don't work when size==0. Override them. */ - if (size==0) { - size=1; - } -#endif /* !defined(MALLOC_ZERO_WORKS) */ - - result = raw_malloc(size); - - if (PREDICT_UNLIKELY(result == NULL)) { - /* LCOV_EXCL_START */ - /* If these functions die within a worker process, they won't call - * spawn_exit, but that's ok, since the parent will run out of memory soon - * anyway. */ - raw_assert_unreached_msg("Out of memory on malloc(). Dying."); - /* LCOV_EXCL_STOP */ - } - return result; -} - -/** Allocate a chunk of size bytes of memory, fill the memory with - * zero bytes, and return a pointer to the result. Log and terminate - * the process on error. (Same as calloc(size,1), but never returns NULL.) - */ -void * -tor_malloc_zero_(size_t size) -{ - /* You may ask yourself, "wouldn't it be smart to use calloc instead of - * malloc+memset? Perhaps libc's calloc knows some nifty optimization trick - * we don't!" Indeed it does, but its optimizations are only a big win when - * we're allocating something very big (it knows if it just got the memory - * from the OS in a pre-zeroed state). We don't want to use tor_malloc_zero - * for big stuff, so we don't bother with calloc. */ - void *result = tor_malloc_(size); - memset(result, 0, size); - return result; -} - -/* The square root of SIZE_MAX + 1. If a is less than this, and b is less - * than this, then a*b is less than SIZE_MAX. (For example, if size_t is - * 32 bits, then SIZE_MAX is 0xffffffff and this value is 0x10000. If a and - * b are less than this, then their product is at most (65535*65535) == - * 0xfffe0001. */ -#define SQRT_SIZE_MAX_P1 (((size_t)1) << (sizeof(size_t)*4)) - -/** Return non-zero if and only if the product of the arguments is exact, - * and cannot overflow. */ -STATIC int -size_mul_check(const size_t x, const size_t y) -{ - /* This first check is equivalent to - (x < SQRT_SIZE_MAX_P1 && y < SQRT_SIZE_MAX_P1) - - Rationale: if either one of x or y is >= SQRT_SIZE_MAX_P1, then it - will have some bit set in its most significant half. - */ - return ((x|y) < SQRT_SIZE_MAX_P1 || - y == 0 || - x <= SIZE_MAX / y); -} - -/** Allocate a chunk of nmemb*size bytes of memory, fill - * the memory with zero bytes, and return a pointer to the result. - * Log and terminate the process on error. (Same as - * calloc(nmemb,size), but never returns NULL.) - * The second argument (size) should preferably be non-zero - * and a compile-time constant. - */ -void * -tor_calloc_(size_t nmemb, size_t size) -{ - raw_assert(size_mul_check(nmemb, size)); - return tor_malloc_zero_((nmemb * size)); -} - -/** Change the size of the memory block pointed to by ptr to size - * bytes long; return the new memory block. On error, log and - * terminate. (Like realloc(ptr,size), but never returns NULL.) - */ -void * -tor_realloc_(void *ptr, size_t size) -{ - void *result; - - raw_assert(size < SIZE_T_CEILING); - -#ifndef MALLOC_ZERO_WORKS - /* Some libc mallocs don't work when size==0. Override them. */ - if (size==0) { - size=1; - } -#endif /* !defined(MALLOC_ZERO_WORKS) */ - - result = raw_realloc(ptr, size); - - if (PREDICT_UNLIKELY(result == NULL)) { - /* LCOV_EXCL_START */ - raw_assert_unreached_msg("Out of memory on realloc(). Dying."); - /* LCOV_EXCL_STOP */ - } - return result; -} - -/** - * Try to realloc ptr so that it takes up sz1 * sz2 bytes. Check for - * overflow. Unlike other allocation functions, return NULL on overflow. - */ -void * -tor_reallocarray_(void *ptr, size_t sz1, size_t sz2) -{ - /* XXXX we can make this return 0, but we would need to check all the - * reallocarray users. */ - raw_assert(size_mul_check(sz1, sz2)); - - return tor_realloc(ptr, (sz1 * sz2)); -} - -/** Return a newly allocated copy of the NUL-terminated string s. On - * error, log and terminate. (Like strdup(s), but never returns - * NULL.) - */ -char * -tor_strdup_(const char *s) -{ - char *duplicate; - raw_assert(s); - - duplicate = raw_strdup(s); - - if (PREDICT_UNLIKELY(duplicate == NULL)) { - /* LCOV_EXCL_START */ - raw_assert_unreached_msg("Out of memory on strdup(). Dying."); - /* LCOV_EXCL_STOP */ - } - return duplicate; -} - -/** Allocate and return a new string containing the first n - * characters of s. If s is longer than n - * characters, only the first n are copied. The result is - * always NUL-terminated. (Like strndup(s,n), but never returns - * NULL.) - */ -char * -tor_strndup_(const char *s, size_t n) -{ - char *duplicate; - raw_assert(s); - raw_assert(n < SIZE_T_CEILING); - duplicate = tor_malloc_((n+1)); - /* Performance note: Ordinarily we prefer strlcpy to strncpy. But - * this function gets called a whole lot, and platform strncpy is - * much faster than strlcpy when strlen(s) is much longer than n. - */ - strncpy(duplicate, s, n); - duplicate[n]='\0'; - return duplicate; -} - -/** Allocate a chunk of len bytes, with the same contents as the - * len bytes starting at mem. */ -void * -tor_memdup_(const void *mem, size_t len) -{ - char *duplicate; - raw_assert(len < SIZE_T_CEILING); - raw_assert(mem); - duplicate = tor_malloc_(len); - memcpy(duplicate, mem, len); - return duplicate; -} - -/** As tor_memdup(), but add an extra 0 byte at the end of the resulting - * memory. */ -void * -tor_memdup_nulterm_(const void *mem, size_t len) -{ - char *duplicate; - raw_assert(len < SIZE_T_CEILING+1); - raw_assert(mem); - duplicate = tor_malloc_(len+1); - memcpy(duplicate, mem, len); - duplicate[len] = '\0'; - return duplicate; -} - -/** Helper for places that need to take a function pointer to the right - * spelling of "free()". */ -void -tor_free_(void *mem) -{ - tor_free(mem); -} diff --git a/src/lib/malloc/util_malloc.h b/src/lib/malloc/util_malloc.h deleted file mode 100644 index a1e9531176..0000000000 --- a/src/lib/malloc/util_malloc.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2003-2004, Roger Dingledine - * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2018, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file util_malloc.h - * \brief Headers for util_malloc.c - **/ - -#ifndef TOR_UTIL_MALLOC_H -#define TOR_UTIL_MALLOC_H - -#include -#include -#include "lib/cc/compat_compiler.h" - -/* Memory management */ -void *tor_malloc_(size_t size) ATTR_MALLOC; -void *tor_malloc_zero_(size_t size) ATTR_MALLOC; -void *tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC; -void *tor_realloc_(void *ptr, size_t size); -void *tor_reallocarray_(void *ptr, size_t size1, size_t size2); -char *tor_strdup_(const char *s) ATTR_MALLOC; -char *tor_strndup_(const char *s, size_t n) - ATTR_MALLOC; -void *tor_memdup_(const void *mem, size_t len) - ATTR_MALLOC; -void *tor_memdup_nulterm_(const void *mem, size_t len) - ATTR_MALLOC; -void tor_free_(void *mem); - -/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, - * etc. Unlike the free() function, the tor_free() macro sets the - * pointer value to NULL after freeing it. - * - * This is a macro. If you need a function pointer to release memory from - * tor_malloc(), use tor_free_(). - * - * Note that this macro takes the address of the pointer it is going to - * free and clear. If that pointer is stored with a nonstandard - * alignment (eg because of a "packed" pragma) it is not correct to use - * tor_free(). - */ -#ifdef __GNUC__ -#define tor_free(p) STMT_BEGIN \ - typeof(&(p)) tor_free__tmpvar = &(p); \ - raw_free(*tor_free__tmpvar); \ - *tor_free__tmpvar=NULL; \ - STMT_END -#else -#define tor_free(p) STMT_BEGIN \ - raw_free(p); \ - (p)=NULL; \ - STMT_END -#endif - -#define tor_malloc(size) tor_malloc_(size) -#define tor_malloc_zero(size) tor_malloc_zero_(size) -#define tor_calloc(nmemb,size) tor_calloc_(nmemb, size) -#define tor_realloc(ptr, size) tor_realloc_(ptr, size) -#define tor_reallocarray(ptr, sz1, sz2) \ - tor_reallocarray_((ptr), (sz1), (sz2)) -#define tor_strdup(s) tor_strdup_(s) -#define tor_strndup(s, n) tor_strndup_(s, n) -#define tor_memdup(s, n) tor_memdup_(s, n) -#define tor_memdup_nulterm(s, n) tor_memdup_nulterm_(s, n) - -/* Aliases for the underlying system malloc/realloc/free. Only use - * them to indicate "I really want the underlying system function, I know - * what I'm doing." */ -#define raw_malloc malloc -#define raw_realloc realloc -#define raw_free free -#define raw_strdup strdup - -/* Helper macro: free a variable of type 'typename' using freefn, and - * set the variable to NULL. - */ -#define FREE_AND_NULL(typename, freefn, var) \ - do { \ - /* only evaluate (var) once. */ \ - typename **tmp__free__ptr ## freefn = &(var); \ - freefn(*tmp__free__ptr ## freefn); \ - (*tmp__free__ptr ## freefn) = NULL; \ - } while (0) - -#ifdef UTIL_MALLOC_PRIVATE -STATIC int size_mul_check(const size_t x, const size_t y); -#endif - -#endif /* !defined(TOR_UTIL_MALLOC_H) */ diff --git a/src/lib/memarea/memarea.c b/src/lib/memarea/memarea.c index 9d494ab2d4..3a93d89ee2 100644 --- a/src/lib/memarea/memarea.c +++ b/src/lib/memarea/memarea.c @@ -19,7 +19,7 @@ #include "lib/container/smartlist.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifndef DISABLE_MEMORY_SENTINELS diff --git a/src/lib/meminfo/meminfo.c b/src/lib/meminfo/meminfo.c index b5a74ce624..01080367fa 100644 --- a/src/lib/meminfo/meminfo.c +++ b/src/lib/meminfo/meminfo.c @@ -16,7 +16,7 @@ #include "lib/cc/torint.h" #include "lib/fs/files.h" #include "lib/log/torlog.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef HAVE_SYS_SYSCTL_H #include diff --git a/src/lib/net/address.c b/src/lib/net/address.c index 3b624da096..ca0c2a46c4 100644 --- a/src/lib/net/address.c +++ b/src/lib/net/address.c @@ -44,7 +44,7 @@ #include "lib/ctime/di_ops.h" #include "lib/log/torlog.h" #include "lib/log/escape.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/net/inaddr.h" #include "lib/string/compat_ctype.h" #include "lib/string/compat_string.h" diff --git a/src/lib/net/resolve.c b/src/lib/net/resolve.c index ff9c93989a..7c8df3e307 100644 --- a/src/lib/net/resolve.c +++ b/src/lib/net/resolve.c @@ -12,7 +12,7 @@ #include "lib/net/address.h" #include "lib/net/inaddr.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/parse_int.h" #include "lib/string/util_string.h" diff --git a/src/lib/process/env.c b/src/lib/process/env.c index 244cd4a4eb..5b959d05f8 100644 --- a/src/lib/process/env.c +++ b/src/lib/process/env.c @@ -11,12 +11,12 @@ #include "orconfig.h" #include "lib/process/env.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/ctime/di_ops.h" #include "lib/container/smartlist.h" #include "lib/log/util_bug.h" #include "lib/log/torlog.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef HAVE_UNISTD_H #include diff --git a/src/lib/process/setuid.c b/src/lib/process/setuid.c index 5423259a66..13b352dad0 100644 --- a/src/lib/process/setuid.c +++ b/src/lib/process/setuid.c @@ -19,7 +19,7 @@ #include "lib/fs/userdb.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef HAVE_SYS_TYPES_H #include diff --git a/src/lib/process/subprocess.c b/src/lib/process/subprocess.c index 9a12f5e76e..d2bbb61c34 100644 --- a/src/lib/process/subprocess.c +++ b/src/lib/process/subprocess.c @@ -16,7 +16,7 @@ #include "lib/log/torlog.h" #include "lib/log/util_bug.h" #include "lib/log/win32err.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/process/env.h" #include "lib/process/waitpid.h" #include "lib/string/compat_ctype.h" diff --git a/src/lib/process/waitpid.c b/src/lib/process/waitpid.c index 27f69b08f0..b829cb1b09 100644 --- a/src/lib/process/waitpid.c +++ b/src/lib/process/waitpid.c @@ -15,7 +15,7 @@ #include "lib/process/waitpid.h" #include "lib/log/torlog.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "ht.h" #ifdef HAVE_SYS_WAIT_H diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c index 25dd6d1c26..7768bee06e 100644 --- a/src/lib/sandbox/sandbox.c +++ b/src/lib/sandbox/sandbox.c @@ -39,7 +39,7 @@ #include "lib/log/torlog.h" #include "lib/cc/torint.h" #include "lib/net/resolve.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/string/scanf.h" #include "tor_queue.h" diff --git a/src/lib/smartlist_core/smartlist_core.c b/src/lib/smartlist_core/smartlist_core.c index b9c5f728ce..8364a8180b 100644 --- a/src/lib/smartlist_core/smartlist_core.c +++ b/src/lib/smartlist_core/smartlist_core.c @@ -11,7 +11,7 @@ **/ #include "lib/err/torerr.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include "lib/smartlist_core/smartlist_core.h" #include diff --git a/src/lib/smartlist_core/smartlist_split.c b/src/lib/smartlist_core/smartlist_split.c index 9c8368f665..f63894869c 100644 --- a/src/lib/smartlist_core/smartlist_split.c +++ b/src/lib/smartlist_core/smartlist_split.c @@ -14,7 +14,7 @@ #include "lib/err/torerr.h" #include "lib/string/util_string.h" #include "lib/string/compat_ctype.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include diff --git a/src/lib/string/printf.c b/src/lib/string/printf.c index f8be3b4704..82d38242dd 100644 --- a/src/lib/string/printf.c +++ b/src/lib/string/printf.c @@ -11,7 +11,7 @@ #include "lib/string/printf.h" #include "lib/err/torerr.h" #include "lib/cc/torint.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #include #include diff --git a/src/lib/term/getpass.c b/src/lib/term/getpass.c index 590411b715..27a27179b6 100644 --- a/src/lib/term/getpass.c +++ b/src/lib/term/getpass.c @@ -11,7 +11,7 @@ #include "lib/term/getpass.h" #include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" +#include "lib/malloc/malloc.h" #ifdef _WIN32 #include -- cgit v1.2.3-54-g00ecf