• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1GCC with `-Wformat-security -Werror=format-security` hardening options enabled
2by default rejects some codes in libcpp. This patch fixes them.
3
4--- 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
6@@ -794,10 +794,10 @@
7
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         }
17
18       result |= CPP_N_INTEGER;
19--- 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
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 		  }
38
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);
45 	      goto out;
46 	    }
47 	  if (!vaopt_tracker.completed ())
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);
54 	      goto out;
55 	    }
56
57