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.
This commit is contained in:
phk 2004-02-21 08:55:38 +00:00
parent 0c90ec6882
commit 9942edab59

View File

@ -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);