diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-11-11 13:08:42 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-11-11 13:31:50 -0500 |
commit | 34952fe5de44a833370cbe87b63fb8eec61466d7 (patch) | |
tree | 6d1cca357ba7a71778fc790db1ae394cd59f0a06 /src/locale | |
parent | 8d37958d58cf36f53d5fcc7a8aa6d633da6071b2 (diff) | |
download | musl-34952fe5de44a833370cbe87b63fb8eec61466d7.tar.gz musl-34952fe5de44a833370cbe87b63fb8eec61466d7.tar.bz2 musl-34952fe5de44a833370cbe87b63fb8eec61466d7.tar.xz musl-34952fe5de44a833370cbe87b63fb8eec61466d7.zip |
convert malloc use under libc-internal locks to use internal allocator
this change lifts undocumented restrictions on calls by replacement
mallocs to libc functions that might take these locks, and sets the
stage for lifting restrictions on the child execution environment
after multithreaded fork.
care is taken to #define macros to replace all four functions (malloc,
calloc, realloc, free) even if not all of them will be used, using an
undefined symbol name for the ones intended not to be used so that any
inadvertent future use will be caught at compile time rather than
directed to the wrong implementation.
Diffstat (limited to 'src/locale')
-rw-r--r-- | src/locale/dcngettext.c | 5 | ||||
-rw-r--r-- | src/locale/locale_map.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/locale/dcngettext.c b/src/locale/dcngettext.c index 4c304393..39a98e83 100644 --- a/src/locale/dcngettext.c +++ b/src/locale/dcngettext.c @@ -11,6 +11,11 @@ #include "pleval.h" #include "lock.h" +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc undef +#define free undef + struct binding { struct binding *next; int dirlen; diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c index e7eede62..94f1b04e 100644 --- a/src/locale/locale_map.c +++ b/src/locale/locale_map.c @@ -1,10 +1,16 @@ #include <locale.h> #include <string.h> #include <sys/mman.h> +#include <stdlib.h> #include "locale_impl.h" #include "libc.h" #include "lock.h" +#define malloc __libc_malloc +#define calloc undef +#define realloc undef +#define free undef + const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) { const char *trans = 0; |