diff --git a/src/filesrch.c b/src/filesrch.c index 111dfd6e7..ad0cf02a1 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -23,6 +23,16 @@ #include #endif #include + +#ifndef S_ISLNK +#define IGNORE_SYMLINKS +#endif + +#ifndef IGNORE_SYMLINKS +#include +#include +#include +#endif #include #include "filesrch.h" @@ -461,6 +471,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want } else if (!strcasecmp(searchname, dent->d_name)) { +#ifndef IGNORE_SYMLINKS + struct stat statbuf; +#endif switch (checkfilemd5(searchpath, wantedmd5sum)) { case FS_FOUND: @@ -468,6 +481,19 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want strcpy(filename,searchpath); else strcpy(filename,dent->d_name); +#ifndef IGNORE_SYMLINKS + if (lstat(filename, &statbuf) != -1) + { + if (S_ISLNK(statbuf.st_mode)) + { + char *tempbuf = realpath(filename, NULL); + if (!tempbuf) + I_Error("Error parsing link %s: %s", filename, strerror(errno)); + strncpy(filename, tempbuf, MAX_WADPATH); + free(tempbuf); + } + } +#endif retval = FS_FOUND; found = 1; break; diff --git a/src/netcode/d_netcmd.c b/src/netcode/d_netcmd.c index dec1ef5a0..0643f8cc0 100644 --- a/src/netcode/d_netcmd.c +++ b/src/netcode/d_netcmd.c @@ -3671,11 +3671,11 @@ static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum) static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { - char filename[241]; + char filename[MAX_WADPATH+1]; filestatus_t ncs = FS_NOTCHECKED; UINT8 md5sum[16]; - READSTRINGN(*cp, filename, 240); + READSTRINGN(*cp, filename, MAX_WADPATH); READMEM(*cp, md5sum, 16); if (playernum != serverplayer)