summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoug <>2014-10-11 03:12:13 +0000
committerdoug <>2014-10-11 03:12:13 +0000
commitd8e4c1f27259e44a2831163d60b152c0e6a1e392 (patch)
treed376cc4cc3bd076608937632e9a0cb89a519e6ae
parent602aac51517412d58a5947dd7477c78b826c54e6 (diff)
downloadopenbsd-d8e4c1f27259e44a2831163d60b152c0e6a1e392.tar.gz
openbsd-d8e4c1f27259e44a2831163d60b152c0e6a1e392.tar.bz2
openbsd-d8e4c1f27259e44a2831163d60b152c0e6a1e392.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--src/lib/libc/net/getprotoent.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/net/getprotoent.c b/src/lib/libc/net/getprotoent.c
index 87060b7b3c..7431566f85 100644
--- a/src/lib/libc/net/getprotoent.c
+++ b/src/lib/libc/net/getprotoent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getprotoent.c,v 1.11 2014/09/15 06:15:48 guenther Exp $ */ 1/* $OpenBSD: getprotoent.c,v 1.12 2014/10/11 03:12:13 doug Exp $ */
2/* 2/*
3 * Copyright (c) 1983, 1993 3 * Copyright (c) 1983, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
@@ -119,8 +119,8 @@ again:
119 continue; 119 continue;
120 } 120 }
121 if (q == &pe->p_aliases[pd->maxaliases - 1]) { 121 if (q == &pe->p_aliases[pd->maxaliases - 1]) {
122 p = realloc(pe->p_aliases, 122 p = reallocarray(pe->p_aliases,
123 2 * pd->maxaliases * sizeof(char *)); 123 pd->maxaliases, 2 * sizeof(char *));
124 if (p == NULL) { 124 if (p == NULL) {
125 serrno = errno; 125 serrno = errno;
126 endprotoent_r(pd); 126 endprotoent_r(pd);