From aa952051fdcf088a559bdfdb8f341a0596338090 Mon Sep 17 00:00:00 2001 From: Sara Sparks Date: Sat, 6 May 2023 20:46:46 -0400 Subject: [PATCH 1/3] Made filesearch aware of symbolic links (cherry picked from commit cbcbda1586d5a19cf17aabedb49bca3e5328fa4f) --- src/filesrch.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/filesrch.c b/src/filesrch.c index 3f901b695..2104d6af5 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -23,6 +23,11 @@ #include #endif #include +#ifndef IGNORE_SYMLINKS +#include +#include +#include +#endif #include #include "filesrch.h" @@ -417,6 +422,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: @@ -424,6 +432,17 @@ 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; From 37ab3e84fc201963d308bfb9dba07f7c82377b28 Mon Sep 17 00:00:00 2001 From: Sara Sparks Date: Mon, 8 May 2023 21:36:09 -0400 Subject: [PATCH 2/3] Increase size of filename buffer --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7417b8bf7..ced743f68 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3658,11 +3658,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) From 13055a1ae4e14f381778e901614984f2dd95fbd4 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Thu, 26 Oct 2023 13:15:36 +0000 Subject: [PATCH 3/3] Update filesrch.c Check if S_ISLNK is defined, if not, skip symlink code --- src/filesrch.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index 9977d69c3..3b6abdf88 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -23,6 +23,11 @@ #include #endif #include + +#ifndef S_ISLNK +#define IGNORE_SYMLINKS +#endif + #ifndef IGNORE_SYMLINKS #include #include @@ -467,8 +472,10 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want else strcpy(filename,dent->d_name); #ifndef IGNORE_SYMLINKS - if (lstat(filename, &statbuf) != -1) { - if (S_ISLNK(statbuf.st_mode)) { + 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));