From: Roy Marples Date: Fri, 19 Apr 2019 20:42:07 +0000 (+0100) Subject: compat: Provide consttime_memequal if not in libc X-Git-Tag: v7.2.1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac90079292168957c3b8b92359a20fb746b15c29;p=thirdparty%2Fdhcpcd.git compat: Provide consttime_memequal if not in libc Public domain version by Matthias Drochner --- diff --git a/configure b/configure index 570e65f2..4f58f0f3 100755 --- a/configure +++ b/configure @@ -13,6 +13,7 @@ IPV4LL= INET6= ARC4RANDOM= CLOSEFROM= +CONSTTIME_MEMEQUAL= STRLCPY= UDEV= OS= @@ -846,6 +847,27 @@ if [ "$STRTOI" = no ]; then echo "#include \"compat/strtoi.h\"" >>$CONFIG_H fi +if [ -z "$CONSTTIME_MEMEQUAL" ]; then + printf "Testing for consttime_memequal ... " + cat <_consttime_memequal.c +#include +int main(void) { + return consttime_memequal("deadbeef", "deadbeef", 8); +} +EOF + if $XCC _consttime_memequal.c -o _consttime_memequal 2>&3; then + CONSTTIME_MEMEQUAL=yes + else + CONSTTIME_MEMEQUAL=no + fi + echo "$CONSTTIME_MEMEQUAL" + rm -f _consttime_memequal.c _consttime_memequal +fi +if [ "$CONSTTIME_MEMEQUAL" = no ]; then + echo "#include \"compat/consttime_memequal.h\"" \ + >>$CONFIG_H +fi + if [ -z "$DPRINTF" ]; then printf "Testing for dprintf ... " cat <_dprintf.c