]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Add a function call stackprotector tests. 157/head
authorDarren Tucker <dtucker@dtucker.net>
Thu, 24 Oct 2019 03:39:49 +0000 (14:39 +1100)
committerDarren Tucker <dtucker@dtucker.net>
Thu, 24 Oct 2019 03:39:49 +0000 (14:39 +1100)
Including a function call in the test programs for the gcc stack
protector flag tests exercises more of the compiler and makes it more
likely it'll detect problems.

configure.ac

index 3e93c0276993fd604b80bae9ae229715bb1cb2b6..8bc96bb45c067e8cb12acd6669e72c584f132274 100644 (file)
@@ -213,20 +213,26 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
                CFLAGS="$CFLAGS $t -Werror"
                LDFLAGS="$LDFLAGS $t -Werror"
                AC_LINK_IFELSE(
-                       [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
+                       [AC_LANG_PROGRAM([[
+       #include <stdio.h>
+       int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
+                        ]],
                        [[
        char x[256];
-       snprintf(x, sizeof(x), "XXX");
+       snprintf(x, sizeof(x), "XXX%d", func(1));
                         ]])],
                    [ AC_MSG_RESULT([yes])
                      CFLAGS="$saved_CFLAGS $t"
                      LDFLAGS="$saved_LDFLAGS $t"
                      AC_MSG_CHECKING([if $t works])
                      AC_RUN_IFELSE(
-                       [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
+                       [AC_LANG_PROGRAM([[
+       #include <stdio.h>
+       int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
+                       ]],
                        [[
        char x[256];
-       snprintf(x, sizeof(x), "XXX");
+       snprintf(x, sizeof(x), "XXX%d", func(1));
                        ]])],
                        [ AC_MSG_RESULT([yes])
                          break ],