1 /* PR preprocessor/79214 - -Wno-system-header defeats strncat buffer overflow
4 { dg-options "-O2" } */
8 typedef __SIZE_TYPE__
size_t;
15 extern size_t size ();
23 void test_bzero (void)
25 bzero (d
, range ()); /* { dg-warning ".__builtin_(bzero|memset). writing 4 or more bytes into a region of size 3 overflows the destination" } */
28 void test_memcpy (void)
30 memcpy (d
, s
, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
33 void test_memmove (void)
35 memmove (d
, d
+ 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" } */
38 void test_mempcpy (void)
40 mempcpy (d
, s
, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
43 void test_memset (int n
)
45 memset (d
, n
, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" } */
48 void test_strcat (int i
)
50 const char *s
= i
< 0 ? "123" : "4567";
52 strcat (d
, s
); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
55 char* test_stpcpy (int i
)
57 const char *s
= i
< 0 ? "123" : "4567";
59 return stpcpy (d
, s
); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
62 char* test_stpncpy (int i
)
64 const char *s
= i
< 0 ? "123" : "4567";
66 return stpncpy (d
, s
, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
69 char* test_strcpy (int i
)
71 const char *s
= i
< 0 ? "123" : "4567";
73 return strcpy (d
, s
); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
76 char* test_strncpy (int i
)
78 const char *s
= i
< 0 ? "123" : "4567";
80 return strncpy (d
, s
, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
83 char* test_strncat (int i
)
85 const char *s
= i
< 0 ? "123" : "4567";
87 return strncat (d
, s
, range ()); /* { dg-warning ".__builtin_strncat. specified bound between 4 and \[0-9\]+" } */