From fe4ab18f6dcb8b0d0b7bb07846ca7582a7e018d8 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Tue, 30 Jul 2013 15:22:17 +0100 Subject: [PATCH] Check for memsetlimit --- configure | 45 +++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 10 ++++++++++ src/main/radsniff.c | 5 +++++ 3 files changed, 60 insertions(+) diff --git a/configure b/configure index 9aa647117e42..a6ea67b128ac 100755 --- a/configure +++ b/configure @@ -8569,6 +8569,51 @@ $as_echo "#define HAVE_THREAD_TLS 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for talloc_set_memlimit in -ltalloc" >&5 +$as_echo_n "checking for talloc_set_memlimit in -ltalloc... " >&6; } +if ${ac_cv_lib_talloc_talloc_set_memlimit+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltalloc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char talloc_set_memlimit (); +int +main () +{ +return talloc_set_memlimit (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_talloc_talloc_set_memlimit=yes +else + ac_cv_lib_talloc_talloc_set_memlimit=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_talloc_talloc_set_memlimit" >&5 +$as_echo "$ac_cv_lib_talloc_talloc_set_memlimit" >&6; } +if test "x$ac_cv_lib_talloc_talloc_set_memlimit" = xyes; then : + + $as_echo "#define HAVE_TALLOC_SET_MEMLIMIT 1 Define to 1 if you have the function talloc_set_memlimit." >>confdefs.h + + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 $as_echo_n "checking for crypt in -lcrypt... " >&6; } if ${ac_cv_lib_crypt_crypt+:} false; then : diff --git a/configure.ac b/configure.ac index 589fbb8e0d7e..24846cd8d84c 100644 --- a/configure.ac +++ b/configure.ac @@ -1304,6 +1304,16 @@ dnl # 7. Checks for library functions dnl # dnl ############################################################# +dnl # +dnl # Check for talloc_set_memlimit +dnl # This was only included in version 2.0.8 +dnl # +AC_CHECK_LIB(talloc, talloc_set_memlimit, + [ + AC_DEFINE(HAVE_TALLOC_SET_MEMLIMIT, 1, [Define to 1 if you have the function talloc_set_memlimit.]) + ] +) + dnl # dnl # Check for libcrypt dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD) diff --git a/src/main/radsniff.c b/src/main/radsniff.c index 6c49e28f9d72..e18a7c31c20e 100644 --- a/src/main/radsniff.c +++ b/src/main/radsniff.c @@ -570,7 +570,12 @@ int main(int argc, char *argv[]) exit (1); } + /* + * We don't really want probes taking down machines + */ +#ifdef HAVE_TALLOC_SET_MEMLIMIT talloc_set_memlimit(conf, 52428800); /* 50 MB */ +#endif /* * Get options