Commit 004ac7b7 by Andrew Benson

Remove check for maximum symbol name length.

        PR fortran/87103
        * expr.c (gfc_check_conformance): Check vsnprintf for truncation.
        * iresolve.c (gfc_get_string): Likewise.
        * symbol.c (gfc_new_symbol): Remove check for maximum symbol
        name length.  Remove redundant 0 setting of new calloc()ed
        gfc_symbol.
parent 59e6d62b
2020-01-30 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
PR fortran/87103
* expr.c (gfc_check_conformance): Check vsnprintf for truncation.
* iresolve.c (gfc_get_string): Likewise.
* symbol.c (gfc_new_symbol): Remove check for maximum symbol
name length. Remove redundant 0 setting of new calloc()ed
gfc_symbol.
2020-01-30 Paul Thomas  <pault@gcc.gnu.org> 2020-01-30 Paul Thomas  <pault@gcc.gnu.org>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
...@@ -3495,8 +3495,10 @@ gfc_check_conformance (gfc_expr *op1, gfc_expr *op2, const char *optype_msgid, . ...@@ -3495,8 +3495,10 @@ gfc_check_conformance (gfc_expr *op1, gfc_expr *op2, const char *optype_msgid, .
return true; return true;
va_start (argp, optype_msgid); va_start (argp, optype_msgid);
vsnprintf (buffer, 240, optype_msgid, argp); d = vsnprintf (buffer, sizeof (buffer), optype_msgid, argp);
va_end (argp); va_end (argp);
if (d < 1 || d >= (int) sizeof (buffer)) /* Reject truncation. */
gfc_internal_error ("optype_msgid overflow: %d", d);
if (op1->rank != op2->rank) if (op1->rank != op2->rank)
{ {
......
...@@ -61,9 +61,12 @@ gfc_get_string (const char *format, ...) ...@@ -61,9 +61,12 @@ gfc_get_string (const char *format, ...)
} }
else else
{ {
int ret;
va_start (ap, format); va_start (ap, format);
vsnprintf (temp_name, sizeof (temp_name), format, ap); ret = vsnprintf (temp_name, sizeof (temp_name), format, ap);
va_end (ap); va_end (ap);
if (ret < 1 || ret >= (int) sizeof (temp_name)) /* Reject truncation. */
gfc_internal_error ("identifier overflow: %d", ret);
temp_name[sizeof (temp_name) - 1] = 0; temp_name[sizeof (temp_name) - 1] = 0;
str = temp_name; str = temp_name;
} }
......
...@@ -3132,25 +3132,9 @@ gfc_new_symbol (const char *name, gfc_namespace *ns) ...@@ -3132,25 +3132,9 @@ gfc_new_symbol (const char *name, gfc_namespace *ns)
gfc_clear_ts (&p->ts); gfc_clear_ts (&p->ts);
gfc_clear_attr (&p->attr); gfc_clear_attr (&p->attr);
p->ns = ns; p->ns = ns;
p->declared_at = gfc_current_locus; p->declared_at = gfc_current_locus;
if (strlen (name) > GFC_MAX_SYMBOL_LEN)
gfc_internal_error ("new_symbol(): Symbol name too long");
p->name = gfc_get_string ("%s", name); p->name = gfc_get_string ("%s", name);
/* Make sure flags for symbol being C bound are clear initially. */
p->attr.is_bind_c = 0;
p->attr.is_iso_c = 0;
/* Clear the ptrs we may need. */
p->common_block = NULL;
p->f2k_derived = NULL;
p->assoc = NULL;
p->dt_next = NULL;
p->fn_result_spec = 0;
return p; return p;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment