mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-13 11:51:22 +08:00
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
This commit is contained in:
parent
4221d00ae0
commit
200cfbe7b9
gcc/fortran
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user