Commit 200cfbe7 by Steven G. Kargl Committed by Tobias Schlüter

re PR fortran/23065 (MAXPATHLEN usage in fortran/{scanner,module}.c)

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
parent 4221d00a
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> 2004-08-16 Huang Chun <chunhuang73@hotmail.com>
* trans-expr.c (gfc_conv_power_op): Evaluate the expression before * trans-expr.c (gfc_conv_power_op): Evaluate the expression before
...@@ -5,7 +13,7 @@ ...@@ -5,7 +13,7 @@
2005-08-14 Asher Langton <langton2@llnl.gov> 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> 2005-08-14 Paul Thomas <pault@gcc.gnu.org>
......
...@@ -517,13 +517,6 @@ typedef struct ...@@ -517,13 +517,6 @@ typedef struct
#endif #endif
#include <limits.h>
#ifndef PATH_MAX
# include <sys/param.h>
# define PATH_MAX MAXPATHLEN
#endif
extern int gfc_suppress_error; extern int gfc_suppress_error;
......
...@@ -3479,14 +3479,22 @@ write_module (void) ...@@ -3479,14 +3479,22 @@ write_module (void)
void void
gfc_dump_module (const char *name, int dump_flag) gfc_dump_module (const char *name, int dump_flag)
{ {
char filename[PATH_MAX], *p; int n;
char *filename, *p;
time_t now; time_t now;
filename[0] = '\0'; n = strlen (name) + strlen (MODULE_EXTENSION) + 1;
if (gfc_option.module_dir != NULL) if (gfc_option.module_dir != NULL)
strcpy (filename, gfc_option.module_dir); {
filename = (char *) alloca (n + strlen (gfc_option.module_dir));
strcat (filename, name); strcpy (filename, gfc_option.module_dir);
strcat (filename, name);
}
else
{
filename = (char *) alloca (n);
strcpy (filename, name);
}
strcat (filename, MODULE_EXTENSION); strcat (filename, MODULE_EXTENSION);
if (!dump_flag) if (!dump_flag)
...@@ -3532,10 +3540,12 @@ gfc_dump_module (const char *name, int dump_flag) ...@@ -3532,10 +3540,12 @@ gfc_dump_module (const char *name, int dump_flag)
void void
gfc_use_module (void) gfc_use_module (void)
{ {
char filename[GFC_MAX_SYMBOL_LEN + 5]; char *filename;
gfc_state_data *p; gfc_state_data *p;
int c, line; int c, line;
filename = (char *) alloca(strlen(module_name) + strlen(MODULE_EXTENSION)
+ 1);
strcpy (filename, module_name); strcpy (filename, module_name);
strcat (filename, MODULE_EXTENSION); strcat (filename, MODULE_EXTENSION);
......
...@@ -164,7 +164,7 @@ gfc_release_include_path (void) ...@@ -164,7 +164,7 @@ gfc_release_include_path (void)
FILE * FILE *
gfc_open_included_file (const char *name) gfc_open_included_file (const char *name)
{ {
char fullname[PATH_MAX]; char *fullname;
gfc_directorylist *p; gfc_directorylist *p;
FILE *f; FILE *f;
...@@ -174,9 +174,7 @@ gfc_open_included_file (const char *name) ...@@ -174,9 +174,7 @@ gfc_open_included_file (const char *name)
for (p = include_dirs; p; p = p->next) for (p = include_dirs; p; p = p->next)
{ {
if (strlen (p->path) + strlen (name) + 1 > PATH_MAX) fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1);
continue;
strcpy (fullname, p->path); strcpy (fullname, p->path);
strcat (fullname, name); strcat (fullname, name);
...@@ -1133,15 +1131,12 @@ form_from_filename (const char *filename) ...@@ -1133,15 +1131,12 @@ form_from_filename (const char *filename)
const char *fileext; const char *fileext;
int i; 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; i = 0;
while ((i < PATH_MAX) && (filename[i] != '\0')) while (filename[i] != '\0')
i++; i++;
/* Improperly terminated or too-long filename. */
if (i == PATH_MAX)
return FORM_UNKNOWN;
/* Find last period. */ /* Find last period. */
while (i >= 0 && (filename[i] != '.')) while (i >= 0 && (filename[i] != '.'))
i--; i--;
......
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