From bff2c8cf7447b2547e9101c8f5fc4607a0944c2a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 31 May 2018 10:29:58 +0300 Subject: [PATCH] - limited length of server CVAR name to 63 characters Due to limitation of network protocol server CVARs with longer names cannot propogate changes of their values properly https://forum.zdoom.org/viewtopic.php?t=60729 --- src/c_cvars.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index 2e8e22eccd..605338b013 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -67,6 +67,19 @@ int cvar_defflags; FBaseCVar::FBaseCVar (const char *var_name, uint32_t flags, void (*callback)(FBaseCVar &)) { + if (var_name != nullptr && (flags & CVAR_SERVERINFO)) + { + // This limitation is imposed by network protocol which uses only 6 bits + // for name's length with terminating null character + static const size_t NAME_LENGHT_MAX = 63; + + if (strlen(var_name) > NAME_LENGHT_MAX) + { + I_FatalError("Name of the server console variable \"%s\" is too long.\n" + "Its length should not exceed %zu characters.\n", var_name, NAME_LENGHT_MAX); + } + } + FBaseCVar *var; var = FindCVar (var_name, NULL);