bind9/lib/isc
Ondřej Surý 015b390f62
Stop using malloc_usable_size and malloc_size
Although the nanual page of malloc_usable_size says:

    Although the excess bytes can be over‐written by the application
    without ill effects, this is not good programming practice: the
    number of excess bytes in an allocation depends on the underlying
    implementation.

it looks like the premise is broken with _FORTIFY_SOURCE=3 on newer
systems and it might return a value that causes program to stop with
"buffer overflow" detected from the _FORTIFY_SOURCE.  As we do have own
implementation that tracks the allocation size that we can use to track
the allocation size, we can stop relying on this introspection function.

Also the newer manual page for malloc_usable_size changed the NOTES to:

    The value returned by malloc_usable_size() may be greater than the
    requested size of the allocation because of various internal
    implementation details, none of which the programmer should rely on.
    This function is intended to only be used for diagnostics and
    statistics; writing to the excess memory without first calling
    realloc(3) to resize the allocation is not supported.  The returned
    value is only valid at the time of the call.

Remove usage of both malloc_usable_size() and malloc_size() to be on the
safe size and only use the internal size tracking mechanism when
jemalloc is not available.

(cherry picked from commit d61712d14e)
2024-08-27 04:49:55 +02:00
..
include Define ISC_ATTR_UNUSED macro for __attribute__((__unused__)) 2024-08-27 04:49:55 +02:00
netmgr Use clang-format-19 to update formatting 2024-08-22 10:25:22 +02:00
.gitignore [master] update gitignore files; use rev-parse to get srcid 2014-06-17 13:49:30 -07:00
aes.c Remove EVP_CIPHER_CTX_new() and EVP_CIPHER_CTX_free() shims 2022-03-02 10:49:47 +00:00
app.c Use EXIT_SUCCESS and EXIT_FAILURE 2024-08-06 15:19:06 +02:00
assertions.c Remove redundant #include <isc/strerr.h> 2022-10-17 16:08:28 +01:00
astack.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
backtrace.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
base32.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
base64.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
buffer.c change ISC__BUFFER macros to inline functions 2022-09-27 00:45:28 -07:00
commandline.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
condition.c Remove redundant #include <isc/strerr.h> 2022-10-17 16:08:28 +01:00
counter.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
crc64.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
dir.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
entropy.c De-duplicate __FILE__, __LINE__ 2022-10-17 16:00:26 +01:00
entropy_private.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
errno.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
errno2result.c Translate POSIX errorcode EROFS to ISC_R_NOPERM 2023-06-14 13:48:25 +01:00
errno2result.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
error.c Include the function name when reporting unexpected errors 2022-10-17 16:00:27 +01:00
event.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
file.c Update sources to Clang 15 formatting 2022-11-29 09:14:07 +01:00
glob.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
hash.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
heap.c Update sources to Clang 15 formatting 2022-11-29 09:14:07 +01:00
hex.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
hmac.c NetBSD has added 'hmac' to libc so rename our uses of hmac 2023-12-14 11:14:04 +11:00
ht.c Fix case insensitive matching in isc_ht hash table implementation 2024-02-11 11:23:28 +01:00
httpd.c Explicitly cast chars to unsigned chars for <ctype.h> functions 2023-09-22 17:01:59 +02:00
interfaceiter.c Remove code to read and parse /proc/net/if_inet6 on Linux 2024-08-19 09:46:07 +00:00
iterated_hash.c Clear OpenSSL errors on SHA failures 2023-09-01 13:45:34 +10:00
jemalloc_shim.h Stop using malloc_usable_size and malloc_size 2024-08-27 04:49:55 +02:00
lex.c Update sources to Clang 15 formatting 2022-11-29 09:14:07 +01:00
lib.c remove isc_bind9 variable 2023-02-09 10:07:39 -08:00
log.c Check the result of dirfd() before calling unlinkat() 2024-08-19 11:23:05 +00:00
Makefile.am Replace isc_fsaccess API with more secure file creation 2023-03-31 16:47:15 +02:00
managers.c De-duplicate __FILE__, __LINE__ 2022-10-17 16:00:26 +01:00
md.c Call ERR_clear_error on EVP_MD_fetch or EVP_##alg error 2023-09-06 15:47:05 +00:00
mem.c Add workaround for jemalloc linking order 2024-01-18 10:40:46 +01:00
mem_p.h Improve stability of the jemalloc workaround 2023-11-01 18:04:07 +01:00
meminfo.c Properly compute the physical memory size 2024-07-31 07:30:39 +00:00
mutex.c Remove redundant #include <isc/strerr.h> 2022-10-17 16:08:28 +01:00
mutexblock.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
net.c Clang-format header file changes 2024-05-17 16:21:35 -07:00
netaddr.c Update the source code formatting using clang-format-17 2023-10-18 09:02:57 +02:00
netmgr_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
netscope.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
nonce.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
openssl_shim.c Do not provide a shim for SSL_SESSION_is_resumable() 2022-06-15 17:02:45 +03:00
openssl_shim.h Do not provide a shim for SSL_SESSION_is_resumable() 2022-06-15 17:02:45 +03:00
os.c Add isc_os_umask() function to get current umask 2023-03-31 16:47:15 +02:00
os_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
parseint.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
picohttpparser.c Update sources to Clang 18 formatting 2024-04-23 12:48:56 +00:00
picohttpparser.h Add picohttpparser.{c.h} from https://github.com/h2o/picohttpparser 2022-10-20 15:49:27 +02:00
pool.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
portset.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
quota.c REQUIRE should not have side effects 2022-07-05 13:04:17 -07:00
radix.c Move isc_mem_put to after node is checked for equality 2023-05-29 13:27:51 +10:00
random.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
ratelimiter.c Don't use reference counting in isc_timer unit 2023-01-18 22:39:26 +01:00
regex.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
region.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
resource.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
result.c Limit isccc_cc_fromwire recursion depth 2023-09-07 19:50:27 +02:00
rwlock.c Update sources to Clang 15 formatting 2022-11-29 09:14:07 +01:00
safe.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
serial.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
siphash.c Accept 'in=NULL' with 'inlen=0' in isc_{half}siphash24 2023-01-10 18:36:08 +11:00
sockaddr.c Add helper function isc_sockaddr_disabled 2024-06-03 13:52:37 +00:00
stats.c Move atomic statscounter next to the non-atomic definition 2024-01-03 20:36:35 +03:00
stdio.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
stdtime.c Change the NS_PER_SEC (and friends) from enum to static const 2024-08-19 15:32:03 +00:00
string.c Use strnstr implementation from FreeBSD if not provided by OS 2022-10-04 15:33:33 +11:00
symtab.c Remove use of the inline keyword used as suggestion to compiler 2022-03-25 08:42:18 +01:00
syslog.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
task.c Don't loop indefinitely when isc_task quantum is 'unlimited' 2024-08-07 08:27:15 +02:00
task_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
taskpool.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
thread.c Remove redundant #include <isc/strerr.h> 2022-10-17 16:08:28 +01:00
time.c Change the NS_PER_SEC (and friends) from enum to static const 2024-08-19 15:32:03 +00:00
timer.c Fix a data race in isc_task_purgeevent() 2024-05-17 12:08:27 +00:00
timer_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
tls.c Disassociate the SSL object from the cached SSL_SESSION 2024-08-07 16:01:03 +00:00
tls_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
tm.c Add FALLTHROUGH macro for __attribute__((fallthrough)) 2022-03-25 08:41:09 +01:00
trampoline.c Improve stability of the jemalloc workaround 2023-11-01 18:04:07 +01:00
trampoline_p.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
url.c Update the source code formatting using clang-format-17 2023-10-18 09:02:57 +02:00
utf8.c Update sources to Clang 15 formatting 2022-11-29 09:14:07 +01:00