[gfortran] Fix butter overrun

Paul Brook paul@codesourcery.com
Sun May 16 21:11:00 GMT 2004


Patch below fixes a buffer overrun when parsing commandline options.

Paul

2004-05-16  Paul Brook  <paul@codesourcery.com>

	* options.c (gfc_handle_module_path_options): Fix buffer overrun.

Index: options.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/options.c,v
retrieving revision 1.3
diff -u -p -r1.3 options.c
--- a/options.c	14 May 2004 13:00:04 -0000	1.3
+++ b/options.c	16 May 2004 21:04:30 -0000
@@ -155,7 +155,7 @@ gfc_handle_module_path_options (const ch
       exit (3);
     }
 
-  gfc_option.module_dir = (char *) gfc_getmem (strlen (arg));
+  gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
   strcpy (gfc_option.module_dir, arg);
   strcat (gfc_option.module_dir, "/");
 }



More information about the Fortran mailing list