PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c

Markus Trippelsdorf markus@trippelsdorf.de
Tue Nov 27 08:32:00 GMT 2012


On 2012.11.26 at 13:58 -0800, H.J. Lu wrote:
> Hi,
> 
> OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
> OPT_SPECIAL_input_file are special options, which aren't in cl_options.
> This patch avoids
> 
> if (!(cl_options[foption->opt_index].flags & CL_TARGET))
> 
> on them.  This patch skips them.  OK to install?

The same fix is necessary for gcc/lto-opts.c.
This solves the issue from PR54795 comment 5, 13 and 20.

2012-11-27  Markus Trippelsdorf  <markus@trippelsdorf.de>

	PR lto/54795
	* lto-opts.c (lto_write_options): Also handle
	OPT_SPECIAL_unknown, OPT_SPECIAL_ignore and
	OPT_SPECIAL_program_name.


diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index a235f41..a61a26f 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -93,6 +93,20 @@ lto_write_options (void)
     {
       struct cl_decoded_option *option = &save_decoded_options[i];
 
+      /* Skip explicitly some common options that we do not need.  */
+      switch (option->opt_index)
+      {
+	case OPT_dumpbase:
+	case OPT_SPECIAL_unknown:
+	case OPT_SPECIAL_ignore:
+	case OPT_SPECIAL_program_name:
+	case OPT_SPECIAL_input_file:
+	  continue;
+
+	default:
+	  break;
+      }
+
       /* Skip frontend and driver specific options here.  */
       if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO)))
 	continue;
@@ -108,17 +122,6 @@ lto_write_options (void)
       if (cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING))
 	continue;
 
-      /* Skip explicitly some common options that we do not need.  */
-      switch (option->opt_index)
-	{
-	case OPT_dumpbase:
-	case OPT_SPECIAL_input_file:
-	  continue;
-
-	default:
-	  break;
-	}
-
       for (j = 0; j < option->canonical_option_num_elements; ++j)
 	append_to_collect_gcc_options (&temporary_obstack, &first_p,
 				       option->canonical_option[j]);
-- 
Markus



More information about the Gcc-patches mailing list