From 4ae411968e188659f00286320cdc9b9376cd010d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 10 Nov 2020 16:22:28 +0800 Subject: [PATCH] Prepare a little surprise for naughty string scanners, ryzom/ryzomcore#604 --- ryzom/server/src/input_output_service/string_manager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ryzom/server/src/input_output_service/string_manager.cpp b/ryzom/server/src/input_output_service/string_manager.cpp index 5b6f005d7..155f95041 100644 --- a/ryzom/server/src/input_output_service/string_manager.cpp +++ b/ryzom/server/src/input_output_service/string_manager.cpp @@ -768,6 +768,8 @@ void CStringManager::requestString(uint32 userId, uint32 stringId) msgout.serialBufferWithSize((uint8*)bmsOut.buffer(), bmsOut.length()); NLNET::CUnifiedNetwork::getInstance()->send( frontendId, msgout ); nldebug( "IOSSM: Sent IMPULSION_UID to %hu (STRING_RESP)", frontendId.get() ); + + // TODO: if (strUtf8.empty() && stringId) ban user } @@ -829,7 +831,7 @@ const std::string &CStringManager::getLanguageCodeString(TLanguages language) return _LanguageCode[language]; nlwarning("Language number %u is out of range, returning english", language); - nlassert(english < NB_LANGUAGES); // just to avoid oopsie + nlctassert(english < NB_LANGUAGES); // just to avoid oopsie return _LanguageCode[english]; } @@ -848,6 +850,11 @@ uint32 CStringManager::storeString(const ucstring &str) } else { + // occasionally create a blank entry, + // this lets us find out if someone is scanning the string cache + if ((rand() & 7) == 0) + _StringBase.push_back(ucstring()); + // create a new entry std::pair ret; ret = _StringIdx.insert(std::make_pair(str, (uint32)_StringBase.size()));