From: Todd C. Miller Date: Mon, 30 Jan 2012 19:09:17 +0000 (-0500) Subject: Verify that we can link executables built with -D_FORTIFY_SOURCE X-Git-Tag: SUDO_1_8_4~36^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c894f802d308cb8d85074e7f610c37c9c546d1d3;p=sudo Verify that we can link executables built with -D_FORTIFY_SOURCE before using it. --- diff --git a/configure b/configure index e01adb2ae..61ddc3f03 100755 --- a/configure +++ b/configure @@ -16379,8 +16379,25 @@ done O_CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" ac_fn_c_check_func "$LINENO" "__sprintf_chk" "ac_cv_func___sprintf_chk" if test "x$ac_cv_func___sprintf_chk" = xyes; then : + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +char buf[4]; (void)sprintf(buf, "%s", "foo"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : OSDEFS="${OSDEFS} -D_FORTIFY_SOURCE=2" fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi CPPFLAGS="$O_CPPFLAGS" diff --git a/configure.in b/configure.in index 15bd08812..3ef0f53ef 100644 --- a/configure.in +++ b/configure.in @@ -2090,7 +2090,9 @@ dnl dnl If libc supports _FORTIFY_SOURCE check functions, use it. dnl O_CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" -AC_CHECK_FUNC(__sprintf_chk, [OSDEFS="${OSDEFS} -D_FORTIFY_SOURCE=2"], []) +AC_CHECK_FUNC(__sprintf_chk, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[char buf[4]; (void)sprintf(buf, "%s", "foo");]])], [OSDEFS="${OSDEFS} -D_FORTIFY_SOURCE=2"], []) +], []) CPPFLAGS="$O_CPPFLAGS" utmp_style=LEGACY