For reference, here are the scripts:
Patch:
diff --git a/src/engine/server/register.cpp b/src/engine/server/register.cpp
index 0b7eb94..b287068 100644
--- a/src/engine/server/register.cpp
+++ b/src/engine/server/register.cpp
@@ -275,7 +275,7 @@ int CRegister::RegisterProcessPacket(CNetChunk *pPacket)
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ERROR: configure your firewall/nat to let through udp on port %d.", g_Config.m_SvPort);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", aBuf);
- RegisterNewState(REGISTERSTATE_ERROR);
+ //RegisterNewState(REGISTERSTATE_ERROR);
return 1;
}
else if(pPacket->m_DataSize == sizeof(SERVERBROWSE_COUNT)+2 &&
Binary patcher:
import argparse
import os
SERVERBROWSE_FWERROR = b'\xff\xff\xff\xfffwer'
def make_executable(path):
"""
Taken from http://stackoverflow.com/a/30463972.
Has obvious race conditions, but whatever...
"""
old_mode = os.stat(path).st_mode
new_mode = old_mode | ((old_mode & 0o444) >> 2) # copy R bits to X
if new_mode != old_mode:
os.chmod(path, new_mode)
def main():
parser = argparse.ArgumentParser(description="Patch a Teeworlds server executable to work around a bug in the registering code.")
parser.add_argument('file', metavar="FILE", help="Filename of the executable to patch")
filename = parser.parse_args().file
file = open(filename, 'rb')
contents = file.read()
fixed = contents.replace(SERVERBROWSE_FWERROR, os.urandom(len(SERVERBROWSE_FWERROR)))
fixed_filename = filename + "_fixed.exe"
open(fixed_filename, 'wb').write(fixed)
make_executable(fixed_filename)
if __name__ == '__main__':
main()