Skip to content

Commit

Permalink
Build System & core/heap: add method to disable heap allocator
Browse files Browse the repository at this point in the history
The heap allocator was found to be hiding a use-after-free error
in an unrelated program (not Atheme IRC Services).

Add a configure option to make mowgli.heap just wrap around
mowgli.alloc directly. This allows hardened memory allocators to
be plugged into the latter, which affect all individual object
allocations made by the former.

The disabled implementation also features more debug logging.
  • Loading branch information
aaronmdjones committed Jan 20, 2019
1 parent 10636cb commit 2ea73fc
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 337 deletions.
18 changes: 18 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ enable_shared
enable_static
with_openssl
enable_examples
enable_heap_allocator
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1373,6 +1374,8 @@ Optional Features:
--disable-shared do not build shared library
--enable-static build static library
--enable-examples build examples
--disable-heap-allocator
Disable the heap allocator
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -4704,6 +4707,20 @@ fi
# Check whether --enable-heap-allocator was given.
if test "${enable_heap_allocator+set}" = set; then :
enableval=$enable_heap_allocator; if test x"$enable_heap_allocator" = x"no"; then :
$as_echo "#define DISABLE_HEAP_ALLOCATOR 1" >>confdefs.h
fi
else
enable_heap_allocator="yes"
fi
# Extract the first word of "tput", so it can be a program name with args.
set dummy tput; ac_word=$2
Expand Down Expand Up @@ -6113,6 +6130,7 @@ cat << _EOF_
Configuration:
OpenSSL support: ${OPENSSL}
Heap allocator: ${enable_heap_allocator}
Examples: ${EXAMPLES}
Now type "make" to build, and "make install" to install.
Expand Down
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ AS_IF([test x"$enable_examples" = x"yes"], [

AC_SUBST(EXAMPLES_BUILD)

AC_ARG_ENABLE([heap-allocator],
[AS_HELP_STRING([--disable-heap-allocator], [Disable the heap allocator])],
[AS_IF([test x"$enable_heap_allocator" = x"no"], [
AC_DEFINE([DISABLE_HEAP_ALLOCATOR], [1], [Disable the heap allocator])])
], [enable_heap_allocator="yes"])

BUILDSYS_INIT
BUILDSYS_TOUCH_DEPS

Expand All @@ -152,6 +158,7 @@ cat << _EOF_

Configuration:
OpenSSL support: ${OPENSSL}
Heap allocator: ${enable_heap_allocator}
Examples: ${EXAMPLES}

Now type "make" to build, and "make install" to install.
Expand Down
Loading

0 comments on commit 2ea73fc

Please sign in to comment.