Skip to content

Instantly share code, notes, and snippets.

@XMPPwocky
Created April 21, 2015 21:13
Show Gist options
  • Save XMPPwocky/d085177814ecb846507d to your computer and use it in GitHub Desktop.
Save XMPPwocky/d085177814ecb846507d to your computer and use it in GitHub Desktop.
int __cdecl CNetChan::IsValidFileForTransfer(char *a1)
{
void *v1; // ecx@1
void *v2; // edi@3
size_t v3; // eax@5
signed int v4; // ebx@5
int retval; // edx@5
char *v6; // edi@6
void *v7; // esi@6
size_t v8; // ST10_4@6
char *trailing_filename; // eax@41
char *extension; // eax@43
const char *v11; // esi@43
int v12; // ecx@52
char strbuf[260]; // [sp+14h] [bp-114h]@6
int v15; // [sp+118h] [bp-10h]@1
v1 = __stack_chk_guard_ptr;
v15 = *(_DWORD *)__stack_chk_guard_ptr;
if ( !a1 )
{
retval = 0;
goto LABEL_52;
}
if ( !*a1 )
{
retval = 0;
goto LABEL_52;
}
v2 = __stack_chk_guard_ptr;
if ( !(unsigned __int8)COM_IsValidPath(a1) || (unsigned __int8)V_IsAbsolutePath(a1) )
goto LABEL_50;
v3 = strlen(a1);
v4 = 0;
retval = 0;
v1 = v2;
if ( (signed int)v3 <= 259 )
{
v6 = strbuf;
v7 = v1;
v8 = v3;
V_strncpy(strbuf, a1, 0x104u);
V_FixSlashes(strbuf, 47);
V_FixDoubleSlashes(strbuf);
v1 = v7;
retval = 0;
if ( (unsigned __int8)strbuf[v8 - 1] != 47 )
{
while ( *v6 )
{
if ( (unsigned __int8)*v6 == 47 )
++v4;
++v6;
}
if ( v4 > 31 )
{
retval = 0;
goto LABEL_52;
}
v2 = v7;
if ( !Q_RemoveAllEvilCharacters(strbuf)
&& !V_stristr(strbuf, "lua/")
&& !V_stristr(strbuf, "gamemodes/")
&& !V_stristr(strbuf, "addons/")
&& !V_stristr(strbuf, "~/")
&& !V_stristr(strbuf, "./././")
&& !V_stristr(strbuf, " ")
&& !V_stristr(strbuf, "\t")
&& !V_stristr(strbuf, ".cfg")
&& !V_stristr(strbuf, ".lst")
&& !V_stristr(strbuf, ".exe")
&& !V_stristr(strbuf, ".vbs")
&& !V_stristr(strbuf, ".com")
&& !V_stristr(strbuf, ".bat")
&& !V_stristr(strbuf, ".cmd")
&& !V_stristr(strbuf, ".dll")
&& !V_stristr(strbuf, ".so")
&& !V_stristr(strbuf, ".dylib")
&& !V_stristr(strbuf, ".ini")
&& !V_stristr(strbuf, ".log")
&& !V_stristr(strbuf, ".lua")
&& !V_stristr(strbuf, ".vdf")
&& !V_stristr(strbuf, ".smx")
&& !V_stristr(strbuf, ".gcf")
&& !V_stristr(strbuf, ".sys") )
{
trailing_filename = strrchr(strbuf, 47);
if ( !trailing_filename )
trailing_filename = strbuf;
extension = strchr(trailing_filename, 46);
v11 = extension;
if ( extension )
{
if ( strlen(extension) - 3 < 2
|| !V_stricmp((char *)v11, ".bsp.bz2")
|| !V_stricmp((char *)v11, ".xbox.vtx")
|| !V_stricmp((char *)v11, ".dx80.vtx")
|| !V_stricmp((char *)v11, ".dx90.vtx")
|| !V_stricmp((char *)v11, ".sw.vtx") )
{
LOBYTE(retval) = strchr(v11, 32) == 0;
goto LABEL_51;
}
}
}
LABEL_50:
retval = 0;
LABEL_51:
v1 = v2;
goto LABEL_52;
}
}
LABEL_52:
v12 = *(_DWORD *)v1;
if ( v12 != v15 )
__stack_chk_fail(v12, retval);
return (unsigned __int8)retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment