]> granicus.if.org Git - sudo/commitdiff
Verify that we can link executables built with -D_FORTIFY_SOURCE
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 30 Jan 2012 20:03:40 +0000 (15:03 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 30 Jan 2012 20:03:40 +0000 (15:03 -0500)
before using it.

--HG--
branch : 1.7

configure
configure.in

index ec3b88bf0ec48bc12d68104d1a1e154044abd2dc..d2eb695c6f08e6d73a6a1f250b71fbb51e829a23 100755 (executable)
--- a/configure
+++ b/configure
@@ -16147,8 +16147,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"
 
index 47b6e3d38856061d111e750c1dd022b9407f62ac..d4e1588216344d8ab7ee906497aaa791ff7e98af 100644 (file)
@@ -2025,7 +2025,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"
 
 AC_CHECK_FUNCS(getutxid getutid, [break])