mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-11-10 07:12:01 +00:00
Fixed FS_OpenFile to only open regular files on filesystem. Fixes server crash with e.g. 'cmd download maps'
This commit is contained in:
parent
4c295390bf
commit
7a79a6b8df
1 changed files with 9 additions and 4 deletions
11
src/files.c
11
src/files.c
|
@ -22,6 +22,8 @@
|
|||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
@ -199,7 +201,7 @@ FS_FOpenFile
|
|||
Finds the file in the search path.
|
||||
returns filesize and an open FILE *
|
||||
Used for streaming data out of either a pak file or
|
||||
a seperate file.
|
||||
a seperate file.<
|
||||
===========
|
||||
*/
|
||||
int file_from_pak = 0;
|
||||
|
@ -207,6 +209,7 @@ int file_from_pak = 0;
|
|||
int FS_FOpenFile(char *filename, FILE **file){
|
||||
searchpath_t *search;
|
||||
char netpath[MAX_OSPATH];
|
||||
struct stat sbuf;
|
||||
pack_t *pak;
|
||||
int i;
|
||||
filelink_t *link;
|
||||
|
@ -250,8 +253,10 @@ int FS_FOpenFile(char *filename, FILE **file){
|
|||
|
||||
Com_sprintf(netpath, sizeof(netpath), "%s/%s", search->filename, filename);
|
||||
|
||||
*file = fopen(netpath, "rb");
|
||||
if(!*file)
|
||||
if(stat(netpath, &sbuf) == -1 || !S_ISREG(sbuf.st_mode))
|
||||
continue;
|
||||
|
||||
if((*file = fopen(netpath, "rb")) == NULL)
|
||||
continue;
|
||||
|
||||
Com_DPrintf("FindFile: %s\n", netpath);
|
||||
|
|
Loading…
Reference in a new issue