[PATCH] gcc/fortran/resolve.c: Let 'err_len' have real effect in gfc_explicit_interface_required()
Chen Gang
gang.chen.5i5j@gmail.com
Mon Jul 28 08:05:00 GMT 2014
External function gfc_explicit_interface_required() assumes the input
parameter 'errmsg' will be a zero terminated string after return, and
the input parameter 'err_len' is full length of 'errmsg'.
If 'err_len' would have real effect -- truncate 'errmsg' by strncpy()
which will zero pad but not be sure of zero terminated, 'errmsg' would
not be zero terminated string.
At present, it is not a bug -- all 'err_len' are large enough for it,
But it is an extern function, according to its interface, it assumes
'errmsg' may be truncated in the future, so still need fix it.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
gcc/fortran/resolve.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 15d8dab..a109168 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2212,6 +2212,10 @@ gfc_explicit_interface_required (gfc_symbol *sym, char *errmsg, int err_len)
{
gfc_formal_arglist *arg = gfc_sym_get_dummy_args (sym);
+ if (--err_len < 0)
+ return false;
+ errmsg[err_len] = '\0';
+
for ( ; arg; arg = arg->next)
{
if (!arg->sym)
--
1.7.11.7
More information about the Gcc-patches
mailing list