summary refs log tree commit diff
path: root/debug
diff options
context:
space:
mode:
Diffstat (limited to 'debug')
-rw-r--r--debug/Makefile24
-rw-r--r--debug/tst-chk1.c42
-rw-r--r--debug/tst-chk4.cc1
-rw-r--r--debug/tst-chk5.cc2
-rw-r--r--debug/tst-chk6.cc2
-rw-r--r--debug/tst-lfschk4.cc2
-rw-r--r--debug/tst-lfschk5.cc2
-rw-r--r--debug/tst-lfschk6.cc2
8 files changed, 61 insertions, 16 deletions
diff --git a/debug/Makefile b/debug/Makefile
index 18905c366f..a2c28f9737 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -79,15 +79,37 @@ CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-tst-chk1.c = -Wno-format
 CFLAGS-tst-chk2.c = -Wno-format
 CFLAGS-tst-chk3.c = -Wno-format
+CFLAGS-tst-chk4.cc = -Wno-format
+CFLAGS-tst-chk5.cc = -Wno-format
+CFLAGS-tst-chk6.cc = -Wno-format
+CFLAGS-tst-lfschk1.c = -Wno-format
+CFLAGS-tst-lfschk2.c = -Wno-format
+CFLAGS-tst-lfschk3.c = -Wno-format
+CFLAGS-tst-lfschk4.cc = -Wno-format
+CFLAGS-tst-lfschk5.cc = -Wno-format
+CFLAGS-tst-lfschk6.cc = -Wno-format
 tst-chk1-ENV = LOCPATH=$(common-objpfx)localedata
 tst-chk2-ENV = LOCPATH=$(common-objpfx)localedata
 tst-chk3-ENV = LOCPATH=$(common-objpfx)localedata
+tst-chk4-ENV = LOCPATH=$(common-objpfx)localedata
+tst-chk5-ENV = LOCPATH=$(common-objpfx)localedata
+tst-chk6-ENV = LOCPATH=$(common-objpfx)localedata
 tst-lfschk1-ENV = LOCPATH=$(common-objpfx)localedata
 tst-lfschk2-ENV = LOCPATH=$(common-objpfx)localedata
 tst-lfschk3-ENV = LOCPATH=$(common-objpfx)localedata
+tst-lfschk4-ENV = LOCPATH=$(common-objpfx)localedata
+tst-lfschk5-ENV = LOCPATH=$(common-objpfx)localedata
+tst-lfschk6-ENV = LOCPATH=$(common-objpfx)localedata
+LDFLAGS-tst-chk4 = -lstdc++
+LDFLAGS-tst-chk5 = -lstdc++
+LDFLAGS-tst-chk6 = -lstdc++
+LDFLAGS-tst-lfschk4 = -lstdc++
+LDFLAGS-tst-lfschk5 = -lstdc++
+LDFLAGS-tst-lfschk6 = -lstdc++
 
 tests = backtrace-tst tst-chk1 tst-chk2 tst-chk3 \
-	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk
+	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
+	tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6
 
 extra-libs = libSegFault libpcprofile
 extra-libs-others = $(extra-libs)
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 26ace28970..78a61be53b 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -49,7 +49,7 @@ do_prepare (void)
     }
 
   const char *strs = "abcdefgh\nABCDEFGHI\nabcdefghij\nABCDEFGHIJ";
-  if (write (temp_fd, strs, strlen (strs)) != strlen (strs))
+  if ((size_t) write (temp_fd, strs, strlen (strs)) != strlen (strs))
     {
       puts ("could not write test strings into file");
       unlink (temp_filename);
@@ -102,7 +102,7 @@ int num2 = 987654;
       chk_fail_ok = 0;				\
       FAIL ();					\
     }
-#if __USE_FORTIFY_LEVEL >= 2
+#if __USE_FORTIFY_LEVEL >= 2 && (!defined __cplusplus || defined __va_arg_pack)
 #define CHK_FAIL2_START CHK_FAIL_START
 #define CHK_FAIL2_END CHK_FAIL_END
 #else
@@ -142,6 +142,12 @@ do_test (void)
 #endif
 	  );
 
+#if defined __USE_FORTIFY_LEVEL && !defined __extern_always_inline
+  printf ("Test skipped");
+  if (l0 == 0)
+    return 0;
+#endif
+
   /* These ops can be done without runtime checking of object size.  */
   memcpy (buf, "abcdefghij", 10);
   memmove (buf + 1, buf, 9);
@@ -280,7 +286,7 @@ do_test (void)
   CHK_FAIL_END
 
   CHK_FAIL_START
-  p = mempcpy (buf + 6, "abcde", l0 + 5);
+  p = (char *) mempcpy (buf + 6, "abcde", l0 + 5);
   CHK_FAIL_END
 
   CHK_FAIL_START
@@ -303,6 +309,7 @@ do_test (void)
   stpncpy (buf + 6, "cd", l0 + 5);
   CHK_FAIL_END
 
+# if !defined __cplusplus || defined __va_arg_pack
   CHK_FAIL_START
   sprintf (buf + 8, "%d", num1);
   CHK_FAIL_END
@@ -310,6 +317,7 @@ do_test (void)
   CHK_FAIL_START
   snprintf (buf + 8, l0 + 3, "%d", num2);
   CHK_FAIL_END
+# endif
 
   memcpy (buf, str1 + 2, l0 + 9);
   CHK_FAIL_START
@@ -330,18 +338,18 @@ do_test (void)
   CHK_FAIL_END
 
   CHK_FAIL_START
-  p = mempcpy (a.buf1 + 6, "abcde", l0 + 5);
+  p = (char *) mempcpy (a.buf1 + 6, "abcde", l0 + 5);
   CHK_FAIL_END
 
   CHK_FAIL_START
   memset (a.buf1 + 9, 'j', l0 + 2);
   CHK_FAIL_END
 
-#if __USE_FORTIFY_LEVEL >= 2
-# define O 0
-#else
-# define O 1
-#endif
+# if __USE_FORTIFY_LEVEL >= 2
+#  define O 0
+# else
+#  define O 1
+# endif
 
   CHK_FAIL_START
   strcpy (a.buf1 + (O + 4), str1 + 5);
@@ -355,6 +363,7 @@ do_test (void)
   strncpy (a.buf1 + (O + 6), "X", l0 + 4);
   CHK_FAIL_END
 
+# if !defined __cplusplus || defined __va_arg_pack
   CHK_FAIL_START
   sprintf (a.buf1 + (O + 7), "%d", num1);
   CHK_FAIL_END
@@ -362,6 +371,7 @@ do_test (void)
   CHK_FAIL_START
   snprintf (a.buf1 + (O + 7), l0 + 3, "%d", num2);
   CHK_FAIL_END
+# endif
 
   memcpy (a.buf1, str1 + (3 - O), l0 + 8 + O);
   CHK_FAIL_START
@@ -919,7 +929,8 @@ do_test (void)
   else
     {
       const char *sendstr = "abcdefgh\nABCDEFGH\n0123456789\n";
-      if (send (sp[0], sendstr, strlen (sendstr), 0) != strlen (sendstr))
+      if ((size_t) send (sp[0], sendstr, strlen (sendstr), 0)
+	  != strlen (sendstr))
 	FAIL ();
 
       char recvbuf[12];
@@ -951,29 +962,30 @@ do_test (void)
       struct sockaddr_un sa_un;
 
       sl = sizeof (sa_un);
-      if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
+      if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK,
+		    (struct sockaddr *) &sa_un, &sl)
 	  != sizeof recvbuf
 	  || memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
 	FAIL ();
 
       sl = sizeof (sa_un);
       if (recvfrom (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK,
-	  &sa_un, &sl) != sizeof recvbuf - 7
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf - 7
 	  || memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
 	FAIL ();
 
 #if __USE_FORTIFY_LEVEL >= 1
       CHK_FAIL_START
       sl = sizeof (sa_un);
-      if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
-	  != sizeof recvbuf)
+      if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK,
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf)
 	FAIL ();
       CHK_FAIL_END
 
       CHK_FAIL_START
       sl = sizeof (sa_un);
       if (recvfrom (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK,
-	  &sa_un, &sl) != sizeof recvbuf - 3)
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf - 3)
 	FAIL ();
       CHK_FAIL_END
 #endif
diff --git a/debug/tst-chk4.cc b/debug/tst-chk4.cc
new file mode 100644
index 0000000000..c82e6aac86
--- /dev/null
+++ b/debug/tst-chk4.cc
@@ -0,0 +1 @@
+#include "tst-chk1.c"
diff --git a/debug/tst-chk5.cc b/debug/tst-chk5.cc
new file mode 100644
index 0000000000..be37ce2d22
--- /dev/null
+++ b/debug/tst-chk5.cc
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 1
+#include "tst-chk1.c"
diff --git a/debug/tst-chk6.cc b/debug/tst-chk6.cc
new file mode 100644
index 0000000000..38b8e4fb36
--- /dev/null
+++ b/debug/tst-chk6.cc
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include "tst-chk1.c"
diff --git a/debug/tst-lfschk4.cc b/debug/tst-lfschk4.cc
new file mode 100644
index 0000000000..f3e6d47d5e
--- /dev/null
+++ b/debug/tst-lfschk4.cc
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk1.c"
diff --git a/debug/tst-lfschk5.cc b/debug/tst-lfschk5.cc
new file mode 100644
index 0000000000..95d4db1d32
--- /dev/null
+++ b/debug/tst-lfschk5.cc
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk2.c"
diff --git a/debug/tst-lfschk6.cc b/debug/tst-lfschk6.cc
new file mode 100644
index 0000000000..50a1ae1258
--- /dev/null
+++ b/debug/tst-lfschk6.cc
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk3.c"