From b6cb0c2696961e9694f84399a32d43063fd1dc4e Mon Sep 17 00:00:00 2001 From: nillerusr Date: Fri, 4 Aug 2023 14:55:13 +0300 Subject: [PATCH] game: fix UB when reading mapcycle --- game/shared/multiplay_gamerules.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/shared/multiplay_gamerules.cpp b/game/shared/multiplay_gamerules.cpp index abecba9e..c380aac7 100644 --- a/game/shared/multiplay_gamerules.cpp +++ b/game/shared/multiplay_gamerules.cpp @@ -1151,12 +1151,14 @@ ConVarRef suitcharger( "sk_suitcharger" ); void StripChar(char *szBuffer, const char cWhiteSpace ) { + char *src, *dst; - while ( char *pSpace = strchr( szBuffer, cWhiteSpace ) ) + for (src = dst = szBuffer; *src != '\0'; src++) { - char *pNextChar = pSpace + sizeof(char); - V_strcpy( pSpace, pNextChar ); + *dst = *src; + if (*dst != cWhiteSpace) dst++; } + *dst = '\0'; } void CMultiplayRules::GetNextLevelName( char *pszNextMap, int bufsize, bool bRandom /* = false */ )