blob: 2b0c95338f3b1e1dcfbae0c5357a2d1edc7eb288 [file] [log] [blame]
Masanori Ogino33f64b52020-09-12 11:20:14 +09001GCC with `-Wformat-security -Werror=format-security` hardening options enabled
2by default rejects some codes in libcpp. This patch fixes them.
3
Elyes Haouas2731fa62023-02-23 16:23:48 +01004--- gcc-8.3.0/libcpp/expr.cc.bak 2020-09-11 15:44:45.770000000 +0900
5+++ gcc-8.3.0/libcpp/expr.cc 2020-09-11 15:46:22.370000000 +0900
Masanori Ogino33f64b52020-09-12 11:20:14 +09006@@ -794,10 +794,10 @@
Patrick Georgib0d87f72021-05-10 23:39:45 +02007
Masanori Ogino33f64b52020-09-12 11:20:14 +09008 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 Georgib0d87f72021-05-10 23:39:45 +020017
Masanori Ogino33f64b52020-09-12 11:20:14 +090018 result |= CPP_N_INTEGER;
Elyes Haouas2731fa62023-02-23 16:23:48 +010019--- gcc-8.3.0/libcpp/macro.cc.bak 2020-09-11 16:01:42.550000000 +0900
20+++ gcc-8.3.0/libcpp/macro.cc 2020-09-11 16:03:47.850000000 +0900
Masanori Ogino33f64b52020-09-12 11:20:14 +090021@@ -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 Georgib0d87f72021-05-10 23:39:45 +020038
Masanori Ogino33f64b52020-09-12 11:20:14 +090039@@ -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 Georgib0d87f72021-05-10 23:39:45 +020045 goto out;
Masanori Ogino33f64b52020-09-12 11:20:14 +090046 }
Patrick Georgib0d87f72021-05-10 23:39:45 +020047 if (!vaopt_tracker.completed ())
Masanori Ogino33f64b52020-09-12 11:20:14 +090048@@ -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 Georgib0d87f72021-05-10 23:39:45 +020054 goto out;
Masanori Ogino33f64b52020-09-12 11:20:14 +090055 }
Patrick Georgib0d87f72021-05-10 23:39:45 +020056