3c33abc520
A function used only in the OpenBSD-Kernel as of now, but it surely provides a helpful interface when you just don't want to make sure the incoming pointer to erealloc() is really NULL so it behaves like malloc, making it a bit more safer. Talking about *allocarray(): It's definitely a major step in code- hardening. Especially as a system administrator, you should be able to trust your core tools without having to worry about segfaults like this, which can easily lead to privilege escalation. How do the GNU coreutils handle this? $ strings -n 4611686018427387903 strings: invalid minimum string length -1 $ strings -n 4611686018427387904 strings: invalid minimum string length 0 They silently overflow... In comparison, sbase: $ strings -n 4611686018427387903 mallocarray: out of memory $ strings -n 4611686018427387904 mallocarray: out of memory The first out of memory is actually a true OOM returned by malloc, whereas the second one is a detected overflow, which is not marked in a special way. Now tell me which diagnostic error-messages are easier to understand. |
||
---|---|---|
.. | ||
agetcwd.c | ||
apathmax.c | ||
concat.c | ||
cp.c | ||
crypt.c | ||
ealloc.c | ||
enmasse.c | ||
eprintf.c | ||
eregcomp.c | ||
estrtod.c | ||
fnck.c | ||
getlines.c | ||
human.c | ||
mallocarray.c | ||
md5.c | ||
mode.c | ||
putword.c | ||
reallocarray.c | ||
recurse.c | ||
rm.c | ||
sha1.c | ||
sha256.c | ||
sha512.c | ||
strcasestr.c | ||
strlcat.c | ||
strlcpy.c | ||
strsep.c | ||
strtonum.c | ||
unescape.c |