]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/23065 (MAXPATHLEN usage in fortran/{scanner,module}.c)
authorSteven G. Kargl <kargls@comcast.net>
Fri, 19 Aug 2005 09:05:03 +0000 (11:05 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Fri, 19 Aug 2005 09:05:03 +0000 (11:05 +0200)
2005-08-19  Steven G. Kargl  <kargls@comcast.net>

PR fortran/23065
* gfortran.h: Remove PATH_MAX definition.
* module.c (write_module, gfc_dump_module): Use alloca to allocate
buffers.
* scanner.s (gfc_release_include_path, form_from_filename): Ditto.

From-SVN: r103271

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/module.c
gcc/fortran/scanner.c

index 87f6e123dd6c888acc255d1cf3ac17c4bd06186b..84dc94a4c005f33b7a306ae029cc0f66b4ce95de 100644 (file)
@@ -1,3 +1,11 @@
+2005-08-19  Steven G. Kargl  <kargls@comcast.net>
+
+       PR fortran/23065
+       * gfortran.h: Remove PATH_MAX definition.
+       * module.c (write_module, gfc_dump_module): Use alloca to allocate
+       buffers.
+       * scanner.s (gfc_release_include_path, form_from_filename): Ditto.
+
 2004-08-16  Huang Chun  <chunhuang73@hotmail.com>
 
        * trans-expr.c (gfc_conv_power_op): Evaluate the expression before
@@ -5,7 +13,7 @@
 
 2005-08-14  Asher Langton  <langton2@llnl.gov>
 
-       * parse.c (match): Enclosed macro in do...while(0) and braces.
+       * parse.c (match): Enclose macro in do...while(0) and braces.
 
 2005-08-14  Paul Thomas  <pault@gcc.gnu.org>
 
index 8ff8d5cdbfe96d3820ebbe38d7435058dc268036..8c33274fd630731f4c4a72749f75380df9a1b7f1 100644 (file)
@@ -517,13 +517,6 @@ typedef struct
 #endif
 
 
-#include <limits.h>
-#ifndef PATH_MAX
-# include <sys/param.h>
-# define PATH_MAX MAXPATHLEN
-#endif
-
-
 extern int gfc_suppress_error;
 
 
index 58af479b90a801026480bd50eb4942a1e9a0a664..db510fdbc3651df5ae6086428d3f542e8f919759 100644 (file)
@@ -3479,14 +3479,22 @@ write_module (void)
 void
 gfc_dump_module (const char *name, int dump_flag)
 {
-  char filename[PATH_MAX], *p;
+  int n;
+  char *filename, *p;
   time_t now;
 
-  filename[0] = '\0';
+  n = strlen (name) + strlen (MODULE_EXTENSION) + 1;
   if (gfc_option.module_dir != NULL)
-    strcpy (filename, gfc_option.module_dir);
-
-  strcat (filename, name);
+    {
+      filename = (char *) alloca (n + strlen (gfc_option.module_dir));
+      strcpy (filename, gfc_option.module_dir);
+      strcat (filename, name);
+    }
+  else
+    {
+      filename = (char *) alloca (n);
+      strcpy (filename, name);
+    }
   strcat (filename, MODULE_EXTENSION);
 
   if (!dump_flag)
@@ -3532,10 +3540,12 @@ gfc_dump_module (const char *name, int dump_flag)
 void
 gfc_use_module (void)
 {
-  char filename[GFC_MAX_SYMBOL_LEN + 5];
+  char *filename;
   gfc_state_data *p;
   int c, line;
 
+  filename = (char *) alloca(strlen(module_name) + strlen(MODULE_EXTENSION)
+                            + 1);
   strcpy (filename, module_name);
   strcat (filename, MODULE_EXTENSION);
 
index d71d065527226abe0d7c87268575a30304cedd2e..68af79d977f59ee895b41a86a04c477b34886bfc 100644 (file)
@@ -164,7 +164,7 @@ gfc_release_include_path (void)
 FILE *
 gfc_open_included_file (const char *name)
 {
-  char fullname[PATH_MAX];
+  char *fullname;
   gfc_directorylist *p;
   FILE *f;
 
@@ -174,9 +174,7 @@ gfc_open_included_file (const char *name)
 
   for (p = include_dirs; p; p = p->next)
     {
-      if (strlen (p->path) + strlen (name) + 1 > PATH_MAX)
-       continue;
-
+      fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1);
       strcpy (fullname, p->path);
       strcat (fullname, name);
 
@@ -1133,15 +1131,12 @@ form_from_filename (const char *filename)
   const char *fileext;
   int i;
 
-  /* Find end of file name.  */
+  /* Find end of file name.  Note, filename is either a NULL pointer or
+     a NUL terminated string.  */
   i = 0;
-  while ((i < PATH_MAX) && (filename[i] != '\0'))
+  while (filename[i] != '\0')
     i++;
 
-  /* Improperly terminated or too-long filename.  */
-  if (i == PATH_MAX)
-    return FORM_UNKNOWN;
-
   /* Find last period.  */
   while (i >= 0 && (filename[i] != '.'))
     i--;