summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-05-03 11:54:25 +0000
committerRoy Marples <roy@marples.name>2016-05-03 11:54:25 +0000
commit687d051ccc596f578107c8e06b6f1e0ee4458e75 (patch)
treedccb6aa1418a8a7c2764f8afe388f3e6087c00b2 /configure
parent1179644e98bc1e9ad09c56dafb172ead5f62da98 (diff)
downloaddhcpcd-687d051ccc596f578107c8e06b6f1e0ee4458e75.tar.xz
Use reallocarray(3) to fix a pontential overflow issue discovered by Coverity.
Provide a shim based on our eloop one if not available in libc.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure29
1 files changed, 29 insertions, 0 deletions
diff --git a/configure b/configure
index 0090c034..a58335ad 100755
--- a/configure
+++ b/configure
@@ -70,6 +70,7 @@ for x do
--with-printf_m) HAVE_PRINTF_M=yes;;
--without-printf_m) HAVE_PRINTF_M=no;;
--without-posix_spawn) POSIX_SPAWN=no;;
+ --without-reallocarrray) REALLOCARRAY=no;;
--without-md5) MD5=no;;
--without-sha2) SHA2=no;;
--without-sha256) SHA2=no;;
@@ -383,6 +384,11 @@ freebsd*|kfreebsd*)
echo "#include <net/if.h>" >>$CONFIG_H
echo "#include <net/if_var.h>" >>$CONFIG_H
;;
+netbsd*)
+ # reallocarray(3) is guarded by _OPENBSD_SOURCE
+ echo "CPPFLAGS+= -D_OPENBSD_SOURCE" >>$CONFIG_MK
+ echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
+ ;;
linux*)
echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
# Large File Support, should be fine for 32-bit systems.
@@ -890,6 +896,29 @@ else
echo "#define HAVE_SPAWN_H" >>$CONFIG_H
fi
+if [ -z "$REALLOCARRAY" ]; then
+ printf "Testing for reallocarray ... "
+ cat <<EOF >_reallocarray.c
+#include <stdlib.h>
+
+int main(void) {
+ reallocarray(NULL, 0, 0);
+ return 0;
+}
+EOF
+ if $XCC _reallocarray.c -o _reallocarray 2>&3; then
+ REALLOCARRAY=yes
+ else
+ REALLOCARRAY=no
+ fi
+ echo "$REALLOCARRAY"
+ rm -f _reallocarray.c _reallocarray
+fi
+if [ "$REALLOCARRAY" = no ]; then
+ echo "COMPAT_SRCS+= compat/reallocarray.c" >>$CONFIG_MK
+ echo "#include \"compat/reallocarray.h\"">>$CONFIG_H
+fi
+
if [ -z "$POLL" ]; then
printf "Testing for kqueue1 ... "
cat <<EOF >_kqueue.c