diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2017-02-18 20:29:39 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2017-02-18 20:29:39 +0000 |
commit | 36426b82f7d1fb9ceed7408f72341e6539e7f34b (patch) | |
tree | 58567c61c739b23816d38f1547a6e30b9a68331c /libexec | |
parent | 65c30be6a8c6e017d12a1c3f6a46d8ec4254028e (diff) |
Add NULL tests to wrterror() to avoid a NULL deref when called from
malloc initialization or a free() error path.
Prompted by libc's malloc.c rev 1.214; with correction from jsg@ and otto@
ok jsg@ krw@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/malloc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libexec/ld.so/malloc.c b/libexec/ld.so/malloc.c index c233d3046f6..7fe0b4e080d 100644 --- a/libexec/ld.so/malloc.c +++ b/libexec/ld.so/malloc.c @@ -172,7 +172,10 @@ hash(void *p) static __dead void wrterror(char *msg) { - _dl_die("%s error: %s", g_pool->func, msg); + if (g_pool != NULL && g_pool->func != NULL) + _dl_die("%s error: %s", g_pool->func, msg); + else + _dl_die("%s", msg); } static void |