Skip to content

Commit c497e23

Browse files
committed
Limit acl object length
1 parent 7642b05 commit c497e23

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Server/mods/deathmatch/logic/CAccessControlListGroup.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,26 @@ void CAccessControlListGroup::WriteToXMLNode(CXMLNode* pNode)
195195
CAccessControlListGroupObject* pObject = *iter;
196196

197197
// Find out the object type string
198-
char szObjectType[255];
198+
std::string strObjectType = "error";
199199
switch (pObject->GetObjectType())
200200
{
201201
case CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE:
202-
strcpy(szObjectType, "resource");
202+
strObjectType = "resource";
203203
break;
204204

205205
case CAccessControlListGroupObject::OBJECT_TYPE_USER:
206-
strcpy(szObjectType, "user");
207-
break;
208-
209-
default:
210-
strcpy(szObjectType, "error");
206+
strObjectType = "user";
211207
break;
212208
}
213209

214210
// Append a dot append the name of the node
215-
strcat(szObjectType, ".");
216-
strncat(szObjectType, pObject->GetObjectName(), NUMELMS(szObjectType) - 1);
211+
strObjectType += ".";
212+
strObjectType += pObject->GetObjectName();
217213

218214
// Create the subnode for this object and write the name attribute we generated
219215
CXMLNode* pObjectNode = pSubNode->CreateSubNode("object");
220216
pAttribute = pObjectNode->GetAttributes().Create("name");
221-
pAttribute->SetValue(szObjectType);
217+
pAttribute->SetValue(strObjectType.c_str());
222218
}
223219
}
224220

Server/mods/deathmatch/logic/luadefs/CLuaACLDefs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ int CLuaACLDefs::aclGroupAddObject(lua_State* luaVM)
746746
argStream.ReadUserData(pGroup);
747747
argStream.ReadString(strObject);
748748

749+
if (strObject.length() > 255)
750+
argStream.SetCustomError(SString("Object name is too long, max length 255, got %d.", strObject.length()));
751+
749752
if (!argStream.HasErrors())
750753
{
751754
// Figure out what type of object this is

0 commit comments

Comments
 (0)