summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2014-10-11 04:22:03 +0000
committerdoug <doug@openbsd.org>2014-10-11 04:22:03 +0000
commita46e67d395d9934d4fc8469fec00475a193599ef (patch)
tree1c6af7fe567b4c0b86c88fbb2119a2411d2e3eab
parentobvious reallocarray() use (diff)
downloadwireguard-openbsd-a46e67d395d9934d4fc8469fec00475a193599ef.tar.xz
wireguard-openbsd-a46e67d395d9934d4fc8469fec00475a193599ef.zip
Userland reallocarray() audit.
Avoid potential integer overflow in the size argument of malloc() and realloc() by using reallocarray() to avoid unchecked multiplication. ok deraadt@
-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);