This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix a buffer overflow in libgfortran (take 2)


On Wed, Apr 09, 2008 at 03:02:05AM -0400, Jakub Jelinek wrote:
> I guess this is the reason why
> nml_read_obj/nml_get_obj_data/nml_parse_qualifier don't call generate_error
> directly:
> 
>   /* Ready to read namelist objects.  If there is an error in input
>      from stdin, output the error message and continue.  */

Actually, even these 3 functions could be modified to call
generate_error/st_printf directly, you could in all these just:
  if (dtp->u.p.current_unit->unit_number != options.stdin_unit)
    generate_error (&dtp->common, LIBERROR_READ_VALUE, 
		    "Repeat count too large for namelist object %s", nl->var_name);
  else
    st_vprintf ("Repeat count too large for namelist object %s", nl->var_name);
or, if you have separate
generate_error (st_parameter_common *cmp, int family, const char *message, ...);
and
generate_verror (st_parameter_common *cmp, int family, const char *message, va_list ap);
you could create a helper routine for these and use that throughout the
above 3 nml_* functions.  generate_error would then just va_start, call
generate_verror and va_end.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]