1 |
12 |
jlechner |
/* Test case for buffer overflow bug in token stringification.
|
2 |
|
|
See PR preprocessor/8055 for details.
|
3 |
|
|
Reported by Alexander N. Kabaev <ak03@gte.com>.
|
4 |
|
|
Test case written by Zack Weinberg <zack@codesourcery.com>. */
|
5 |
|
|
|
6 |
|
|
/* { dg-do preprocess } */
|
7 |
|
|
|
8 |
|
|
#define S(x) #x
|
9 |
|
|
|
10 |
|
|
/* Fill up one internal buffer with data. */
|
11 |
|
|
S(1234567890123456789012345678901234567890123456789012345678901234567890
|
12 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
13 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
14 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
15 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
16 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
17 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
18 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
19 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
20 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
21 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
22 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
23 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
24 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
25 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
26 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
27 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
28 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
29 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
30 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
31 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
32 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
33 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
34 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
35 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
36 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
37 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
38 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
39 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
40 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
41 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
42 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
43 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
44 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
45 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
46 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
47 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
48 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
49 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
50 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
51 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
52 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
53 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
54 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
55 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
56 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
57 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
58 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
59 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
60 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
61 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
62 |
|
|
1234567890123456789012345678901234567890123456789012345678901234567890
|
63 |
|
|
12345678901234567890123456789012345678901234567890123456789012345)
|
64 |
|
|
|
65 |
|
|
/* When stringify_arg() was called with an empty macro argument, it would
|
66 |
|
|
advance the buffer pointer by one but fail to check for running past the
|
67 |
|
|
end of the buffer. We can only know where the end of the buffer is to
|
68 |
|
|
within about eight bytes, so do this sixteen times to be sure of hitting
|
69 |
|
|
it. */
|
70 |
|
|
|
71 |
|
|
S()
|
72 |
|
|
S()
|
73 |
|
|
S()
|
74 |
|
|
S()
|
75 |
|
|
S()
|
76 |
|
|
S()
|
77 |
|
|
S()
|
78 |
|
|
S()
|
79 |
|
|
S()
|
80 |
|
|
S()
|
81 |
|
|
S()
|
82 |
|
|
S()
|
83 |
|
|
S()
|
84 |
|
|
S()
|
85 |
|
|
S()
|
86 |
|
|
S()
|
87 |
|
|
|
88 |
|
|
/* Now allocate more memory in the buffer, which should provoke a crash. */
|
89 |
|
|
|
90 |
|
|
S(abcdefghijklmnopqrstuvwxyz)
|
91 |
|
|
S(abcdefghijklmnopqrstuvwxyz)
|