Index: common/ioz.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/ioz.c,v retrieving revision 1.10 diff -u -r1.10 ioz.c --- common/ioz.c 2002/03/05 15:46:22 1.10 +++ common/ioz.c 2002/05/18 17:28:25 @@ -73,7 +73,11 @@ { fz_FILE *fp; char mode[64]; - + + if (!is_reg_file(filename)) { + return NULL; + } + fp = (fz_FILE *)fc_malloc(sizeof(*fp)); sz_strlcpy(mode, in_mode); Index: common/support.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/support.c,v retrieving revision 1.17 diff -u -r1.17 support.c --- common/support.c 2002/05/17 06:21:16 1.17 +++ common/support.c 2002/05/18 17:28:26 @@ -48,6 +48,8 @@ #include #include #include +#include +#include #ifdef HAVE_UNISTD_H #include /* usleep, fcntl, gethostname */ @@ -473,3 +475,14 @@ } #endif + +/********************************************************************** + Returns TRUE iff the file is a regular file or a link to a regular + file. +***********************************************************************/ +bool is_reg_file(const char *name) +{ + struct stat tmp; + + return stat(name, &tmp) == 0 && S_ISREG(tmp.st_mode); +} Index: common/support.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/support.h,v retrieving revision 1.11 diff -u -r1.11 support.h --- common/support.h 2002/03/05 15:46:24 1.11 +++ common/support.h 2002/05/18 17:28:26 @@ -28,6 +28,7 @@ #endif #include "attribute.h" +#include "shared.h" /* bool type */ int mystrcasecmp(const char *str0, const char *str1); int mystrncasecmp(const char *str0, const char *str1, size_t n); @@ -54,5 +55,7 @@ void my_init_console(void); char *my_read_console(void); #endif + +bool is_reg_file(const char *name); #endif /* FC__SUPPORT_H */ Index: server/stdinhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v retrieving revision 1.224 diff -u -r1.224 stdinhand.c --- server/stdinhand.c 2002/05/14 19:40:42 1.224 +++ server/stdinhand.c 2002/05/18 17:28:30 @@ -1776,13 +1776,12 @@ void read_init_script(struct connection *caller, char *script_filename) { FILE *script_file; - char buffer[MAX_LEN_CONSOLE_LINE]; freelog(LOG_NORMAL, _("Loading script file: %s"), script_filename); - script_file = fopen(script_filename,"r"); - - if (script_file) { - + + if (is_reg_file(script_filename) + && (script_file = fopen(script_filename, "r"))) { + char buffer[MAX_LEN_CONSOLE_LINE]; /* the size is set as to not overflow buffer in handle_stdin_input */ while(fgets(buffer,MAX_LEN_CONSOLE_LINE-1,script_file)) handle_stdin_input((struct connection *)NULL, buffer); @@ -1793,6 +1792,7 @@ _("Cannot read command line scriptfile '%s'."), script_filename); freelog(LOG_ERROR, _("Could not read script file '%s'."), script_filename); + exit(EXIT_FAILURE); } }