1/* 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. */ 11S(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 71S() 72S() 73S() 74S() 75S() 76S() 77S() 78S() 79S() 80S() 81S() 82S() 83S() 84S() 85S() 86S() 87 88/* Now allocate more memory in the buffer, which should provoke a crash. */ 89 90S(abcdefghijklmnopqrstuvwxyz) 91S(abcdefghijklmnopqrstuvwxyz) 92