summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2014-10-11 04:22:04 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2014-10-11 04:22:04 +0000
commite76b59f7f7726aef156831251a30ba0de1990bb7 (patch)
tree076a141ece39598982bbf8dadbb76710c16c2bc1 /lib
parent6da3582fc226f92643fec4637036640505cc2b91 (diff)
Userland reallocarray() audit.
Avoid potential integer overflow in the size argument of malloc() and realloc() by using reallocarray() to avoid unchecked multiplication. ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/getservent.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index 7e3293389d6..dc43da0a8b5 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getservent.c,v 1.13 2014/09/15 06:15:48 guenther Exp $ */
+/* $OpenBSD: getservent.c,v 1.14 2014/10/11 04:22:03 doug Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -122,8 +122,8 @@ again:
continue;
}
if (q == &se->s_aliases[sd->maxaliases - 1]) {
- p = realloc(se->s_aliases,
- 2 * sd->maxaliases * sizeof(char *));
+ p = reallocarray(se->s_aliases, sd->maxaliases,
+ 2 * sizeof(char *));
if (p == NULL) {
serrno = errno;
endservent_r(sd);