Merge branch 'custom-2.2.10' into 'next'

Made filesearch aware of symbolic links

See merge request STJr/SRB2!1976
This commit is contained in:
Logan Aerl Arias 2024-01-01 04:51:09 +00:00
commit 520d1c16da
2 changed files with 28 additions and 2 deletions

View file

@ -23,6 +23,16 @@
#include <windows.h>
#endif
#include <sys/stat.h>
#ifndef S_ISLNK
#define IGNORE_SYMLINKS
#endif
#ifndef IGNORE_SYMLINKS
#include <unistd.h>
#include <libgen.h>
#include <limits.h>
#endif
#include <string.h>
#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;

View file

@ -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)