diff options
author | phk <phk@FreeBSD.org> | 2004-02-21 08:55:38 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-02-21 08:55:38 +0000 |
commit | 9942edab59904c839d523322dee54c39381b8d8f (patch) | |
tree | 56f0e74ae2fa09a15f7393f84fcb1479a89ce7d7 | |
parent | 0c90ec6882debe4c12582eb39cf69236153ce76e (diff) | |
download | FreeBSD-src-9942edab59904c839d523322dee54c39381b8d8f.zip FreeBSD-src-9942edab59904c839d523322dee54c39381b8d8f.tar.gz |
Move the check for sensitive processes to the point where the exception
has been hit, this makes it cover more cases.
Call the message function directly rather than fiddle with flag-saving
when we find an unknown character in our options.
The 'A' flag should not trigger on legal out of memory conditions.
-rw-r--r-- | lib/libc/stdlib/malloc.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index b842ac8..c867aba 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -315,7 +315,11 @@ static void wrtwarning(char *p) { - if (malloc_abort) + /* + * Sensitive processes, somewhat arbitrarily defined here as setuid, + * setgid, root and wheel cannot afford to have malloc mistakes. + */ + if (malloc_abort || issetugid() || getuid() == 0 || getgid() == 0) wrterror(p); _malloc_message(_getprogname(), malloc_func, " warning: ", p); } @@ -458,21 +462,13 @@ malloc_init(void) case 'z': malloc_zero = 0; break; case 'Z': malloc_zero = 1; break; default: - j = malloc_abort; - malloc_abort = 0; - wrtwarning("unknown char in MALLOC_OPTIONS\n"); - malloc_abort = j; + _malloc_message(_getprogname(), malloc_func, + " warning: ", "unknown char in MALLOC_OPTIONS\n"); break; } } } - /* - * Sensitive processes, somewhat arbitrarily defined here as setuid, - * setgid, root and wheel cannot afford to have malloc mistakes. - */ - if (issetugid() || getuid() == 0 || getgid() == 0) - malloc_abort = 1; UTRACE(0, 0, 0); @@ -751,9 +747,6 @@ imalloc(size_t size) else result = malloc_pages(size); - if (malloc_abort && result == NULL) - wrterror("allocation failed\n"); - if (malloc_zero && result != NULL) memset(result, 0, size); |