sbase/libutil
FRIGN 3b825735d8 Implement reallocarray()
Stateless and I stumbled upon this issue while discussing the
semantics of read, accepting a size_t but only being able to return
ssize_t, effectively lacking the ability to report successful
reads > SSIZE_MAX.
The discussion went along and we came to the topic of input-based
memory allocations. Basically, it was possible for the argument
to a memory-allocation-function to overflow, leading to a segfault
later.
The OpenBSD-guys came up with the ingenious reallocarray-function,
and I implemented it as ereallocarray, which automatically returns
on error.
Read more about it here[0].

A simple testcase is this (courtesy to stateless):
$ sbase-strings -n (2^(32|64) / 4)

This will segfault before this patch and properly return an OOM-
situation afterwards (thanks to the overflow-check in reallocarray).

[0]: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3
2015-03-10 21:23:36 +01:00
..
agetcwd.c Fix off-by-one in apathmax() as the path is relative to "/" 2015-03-06 23:50:39 +00:00
apathmax.c Fix off-by-one in apathmax() as the path is relative to "/" 2015-03-06 23:50:39 +00:00
concat.c
cp.c Fix off-by-one in apathmax() as the path is relative to "/" 2015-03-06 23:50:39 +00:00
crypt.c Make already audited tools argv-centric instead of argc-centric 2015-03-02 14:19:26 +01:00
ealloc.c add estrndup 2015-02-11 01:17:21 +00:00
enmasse.c Fix off-by-one in apathmax() as the path is relative to "/" 2015-03-06 23:50:39 +00:00
eprintf.c
eregcomp.c
estrtod.c
fnck.c Refactor enmasse() and recurse() to reflect depth 2015-03-02 22:50:38 +01:00
getlines.c Make getlines() less verbose 2015-02-12 14:34:07 +00:00
human.c
md5.c
mode.c
putword.c
reallocarray.c Implement reallocarray() 2015-03-10 21:23:36 +01:00
recurse.c Use path[len] instead of *(path + len) 2015-03-03 00:31:27 +01:00
rm.c Refactor enmasse() and recurse() to reflect depth 2015-03-02 22:50:38 +01:00
sha1.c
sha256.c
sha512.c
strcasestr.c
strlcat.c
strlcpy.c
strsep.c
strtonum.c Use strtonum and libutf in test(1), refactor code and manpage 2015-02-09 22:21:23 +01:00
unescape.c Add \e, \", \' and hex-escapes (\xH[H]) to unescape() 2015-02-14 22:55:37 +01:00