aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/rpc
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2017-03-12 16:03:34 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2017-03-12 16:03:34 +0000
commit9f36610f9ef53017afbc50520b999882958c402c (patch)
tree48681fad678d71728cf4d1e2f4b92b96a5fad900 /lib/libc/rpc
parentab23521a4954485a56e9016dfbde6e7edff6c516 (diff)
downloadsrc-9f36610f9ef53017afbc50520b999882958c402c.tar.gz
src-9f36610f9ef53017afbc50520b999882958c402c.zip
libc: provide some bounds-checking through reallocarray(3).
reallocarray(3) is a non portable extension that originated in OpenBSD. Given that it is already in FreeBSD's libc it is useful for the cases where reallocation involves a multiplication. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9955
Notes
Notes: svn path=/head/; revision=315162
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r--lib/libc/rpc/getnetconfig.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c
index 6d504c5f55ff..40e5a1bad7f0 100644
--- a/lib/libc/rpc/getnetconfig.c
+++ b/lib/libc/rpc/getnetconfig.c
@@ -630,8 +630,8 @@ parse_ncp(char *stringp, struct netconfig *ncp)
ncp->nc_lookups = NULL;
ncp->nc_nlookups = 0;
while ((cp = tokenp) != NULL) {
- if ((nc_lookups = realloc(ncp->nc_lookups,
- (ncp->nc_nlookups + 1) * sizeof *ncp->nc_lookups)) == NULL) {
+ if ((nc_lookups = reallocarray(ncp->nc_lookups,
+ ncp->nc_nlookups + 1, sizeof(*ncp->nc_lookups))) == NULL) {
free(ncp->nc_lookups);
ncp->nc_lookups = NULL;
return (-1);