gcc/libgfortran/intrinsics/rename.c

99 lines
3.1 KiB
C
Raw Normal View History

Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
/* Implementation of the RENAME intrinsic.
Copyright (C) 2005-2015 Free Software Foundation, Inc.
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
This file is part of the GNU Fortran runtime library (libgfortran).
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
Libgfortran is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
Libgfortran is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
#include "libgfortran.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
static int
rename_internal (char *path1, char *path2, gfc_charlen_type path1_len,
gfc_charlen_type path2_len)
{
char *str1 = fc_strdup (path1, path1_len);
char *str2 = fc_strdup (path2, path2_len);
int val = rename (str1, str2);
free (str1);
free (str2);
return ((val == 0) ? 0 : errno);
}
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
/* SUBROUTINE RENAME(PATH1, PATH2, STATUS)
CHARACTER(len=*), INTENT(IN) :: PATH1, PATH2
INTEGER, INTENT(OUT), OPTIONAL :: STATUS */
extern void rename_i4_sub (char *, char *, GFC_INTEGER_4 *, gfc_charlen_type,
gfc_charlen_type);
iexport_proto(rename_i4_sub);
void
rename_i4_sub (char *path1, char *path2, GFC_INTEGER_4 *status,
gfc_charlen_type path1_len, gfc_charlen_type path2_len)
{
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
int val = rename_internal (path1, path2, path1_len, path2_len);
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
if (status != NULL)
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
*status = val;
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
}
iexport(rename_i4_sub);
extern void rename_i8_sub (char *, char *, GFC_INTEGER_8 *, gfc_charlen_type,
gfc_charlen_type);
iexport_proto(rename_i8_sub);
void
rename_i8_sub (char *path1, char *path2, GFC_INTEGER_8 *status,
gfc_charlen_type path1_len, gfc_charlen_type path2_len)
{
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
int val = rename_internal (path1, path2, path1_len, path2_len);
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
if (status != NULL)
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
*status = val;
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
}
iexport(rename_i8_sub);
extern GFC_INTEGER_4 rename_i4 (char *, char *, gfc_charlen_type,
gfc_charlen_type);
export_proto(rename_i4);
GFC_INTEGER_4
rename_i4 (char *path1, char *path2, gfc_charlen_type path1_len,
gfc_charlen_type path2_len)
{
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
return rename_internal (path1, path2, path1_len, path2_len);
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
}
extern GFC_INTEGER_8 rename_i8 (char *, char *, gfc_charlen_type,
gfc_charlen_type);
export_proto(rename_i8);
GFC_INTEGER_8
rename_i8 (char *path1, char *path2, gfc_charlen_type path1_len,
gfc_charlen_type path2_len)
{
PR 60324 Unbounded stack allocations in libgfortran. 2014-11-13 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/60324 * configure: Regenerated. * configure.ac (AM_CFLAGS): Add Werror=vla. * libgfortran.h (gfc_alloca): Remove macro. (fc_strdup_notrim): New prototype. * intrinsics/access.c (access_func): Use fc_strdup rather than stack allocation. * intrinsics/chdir.c (chdir_i4_sub): Likewise. (chdir_i8_sub): Likewise. * intrinsics/chmod.c (chmod_internal): New function, move logic here. (chmod_func): Call chmod_internal. * intrinsics/env.c (getenv): Use fc_strdup rather than stack allocation. (get_environment_variable_i4): Likewise. * intrinsics/execute_command_line.c (execute_command_line): Likewise. * intrinsics/hostnm.c (hostnm_0): New function, use static buffer rather than VLA. (hostnm_i4_sub): Call hostnm_0. (hostnm_i8_sub): Likewise. (hostnm): Likewise. * intrinsics/link.c (link_internal): New function, use fc_strdup rather than stack allocation. (link_i4_sub): Call link_internal. (link_i8_sub): Likewise. (link_i4): Likewise. (link_i8): Likewise. * intrinsics/perror.c (perror_sub): Use fc_strdup rather than stack allocation. * intrinsics/random.c (random_seed_i4): Use static buffer rather than VLA, use _Static_assert to make sure it's big enough. * intrinsics/rename.c (rename_internal): New function, use fc_strdup rather than stack allocation. (rename_i4_sub): Call rename_internal. (rename_i8_sub): Likewise. (rename_i4): Likewise. (rename_i8): Likewise. * intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than stack allocation. (stat_i8_sub_0): Likewise. * intrinsics/symlink.c (symlnk_internal): New function, use fc_strdup rather than stack allocation. (symlnk_i4_sub): Call symlnk_internal. (symlnk_i8_sub): Likewise. (symlnk_i4): Likewise. (symlnk_i8): Likewise. * intrinsics/system.c (system_sub): Use fc_strdup rather than stack allocation. * intrinsics/unlink.c (unlink_i4_sub): Likewise. * io/file_pos.c (READ_CHUNK): Make it a macro rather than variable. * io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * io/read.c (read_f): Likewise. * io/transfer.c (MAX_READ): Make it a macro rather than variable. (WRITE_CHUNK): Likewise. * io/write_float.def (write_float): Use fixed stack buffer, fall back to xmalloc/free for large sizes. * runtime/string.c (fc_strdup_notrim): New function. From-SVN: r217480
2014-11-13 13:05:01 +01:00
return rename_internal (path1, path2, path1_len, path2_len);
Makefile.am: Added new files. * Makefile.am: Added new files. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure.ac: add checks for signal.h headers file, as well as following functions: chdir, strerror, getlogin, gethostname, kill, link, symlink, perror, sleep, time. * configure: Regenerate. * intrinsics/chdir.c, intrinsics/gerror.c, intrinsics/getlog.c, intrinsics/hostnm.c, intrinsics/ierrno.c, intrinsics/kill.c, intrinsics/link.c, intrinsics/perror.c, intrinsics/rename.c, intrinsics/sleep.c, intrinsics/symlnk.c, intrinsics/time.c: Newly implementend g77 intrinsics. * check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill, gfc_check_kill_sub, gfc_check_link, gfc_check_link_sub, gfc_check_symlnk, gfc_check_symlnk_sub, gfc_check_rename, gfc_check_rename_sub, gfc_check_sleep_sub, gfc_check_gerror, gfc_check_getlog, gfc_check_hostnm, gfc_check_hostnm_sub, gfc_check_perror): new functions to check newly implemented g77 intrinsics. * gfortran.h: adding symbols for new intrinsics. * intrinsic.c (add_functions): adding new intrinsics. (add_subroutines): adding new intrinsics. * intrinsic.h: prototype for all checking and resolving functions. * iresolve.c (gfc_resolve_chdir, gfc_resolve_chdir_sub, gfc_resolve_hostnm, gfc_resolve_ierrno, gfc_resolve_kill, gfc_resolve_link, gfc_resolve_rename, gfc_resolve_symlnk, gfc_resolve_time, gfc_resolve_time8, gfc_resolve_rename_sub, gfc_resolve_kill_sub, gfc_resolve_link_sub, gfc_resolve_symlnk_sub, gfc_resolve_sleep_sub, gfc_resolve_gerror, gfc_resolve_getlog, gfc_resolve_hostnm_sub, gfc_resolve_perror): new functions to resolve intrinsics. * trans-intrinsic.c (gfc_conv_intrinsic_function): add case for new symbols. * g77_intrinsics_funcs.f: New test. * g77_intrinsics_sub.f: New test. From-SVN: r96893
2005-03-22 23:08:22 +01:00
}