Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 1 | GCC with `-Wformat-security -Werror=format-security` hardening options enabled |
| 2 | by default rejects some codes in libcpp. This patch fixes them. |
| 3 | |
| 4 | --- gcc-8.3.0/libcpp/expr.c.bak 2020-09-11 15:44:45.770000000 +0900 |
| 5 | +++ gcc-8.3.0/libcpp/expr.c 2020-09-11 15:46:22.370000000 +0900 |
| 6 | @@ -794,10 +794,10 @@ |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 7 | |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 8 | if (CPP_OPTION (pfile, c99)) |
| 9 | cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location, |
| 10 | - 0, message); |
| 11 | + 0, "%s", message); |
| 12 | else |
| 13 | cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG, |
| 14 | - virtual_location, 0, message); |
| 15 | + virtual_location, 0, "%s", message); |
| 16 | } |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 17 | |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 18 | result |= CPP_N_INTEGER; |
| 19 | --- gcc-8.3.0/libcpp/macro.c.bak 2020-09-11 16:01:42.550000000 +0900 |
| 20 | +++ gcc-8.3.0/libcpp/macro.c 2020-09-11 16:03:47.850000000 +0900 |
| 21 | @@ -160,7 +160,7 @@ |
| 22 | if (m_state == 2 && token->type == CPP_PASTE) |
| 23 | { |
| 24 | cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, |
| 25 | - vaopt_paste_error); |
| 26 | + "%s", vaopt_paste_error); |
| 27 | return ERROR; |
| 28 | } |
| 29 | /* Advance states before further considering this token, in |
| 30 | @@ -189,7 +189,7 @@ |
| 31 | if (was_paste) |
| 32 | { |
| 33 | cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, |
| 34 | - vaopt_paste_error); |
| 35 | + "%s", vaopt_paste_error); |
| 36 | return ERROR; |
| 37 | } |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 38 | |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 39 | @@ -3361,7 +3361,7 @@ |
| 40 | function-like macros, but not at the end. */ |
| 41 | if (following_paste_op) |
| 42 | { |
| 43 | - cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); |
| 44 | + cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 45 | goto out; |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 46 | } |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 47 | if (!vaopt_tracker.completed ()) |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 48 | @@ -3374,7 +3374,7 @@ |
| 49 | function-like macros, but not at the beginning. */ |
| 50 | if (macro->count == 1) |
| 51 | { |
| 52 | - cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); |
| 53 | + cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 54 | goto out; |
Masanori Ogino | 33f64b5 | 2020-09-12 11:20:14 +0900 | [diff] [blame] | 55 | } |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 56 | |