From f9c2c879c48c74c2adab871d3c36208f14fcece5 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 27 Aug 2016 04:03:24 +0300 Subject: [PATCH] Add extra validation when assigning a player name. --- source/Entity/Player.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 0e27c895..62c7ddc9 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -344,10 +344,20 @@ void CPlayer::SetName(CSStr name) const // Validate the managed identifier Validate(); // Perform the requested operation - if (_Func->SetPlayerName(m_ID, name) == vcmpErrorInvalidName) + const vcmpError ret = _Func->SetPlayerName(m_ID, name); + // Validate the resulted status + if (ret == vcmpErrorNullArgument) + { + STHROWF("Cannot assign a null name to a player"); + } + else if (ret == vcmpErrorInvalidName) { STHROWF("The specified name is invalid"); } + else if (ret == vcmpErrorTooLargeInput) + { + STHROWF("The specified name is too large"); + } } // ------------------------------------------------------------------------------------------------