From d3837038ebdce1c7915dc85db810264b43a55c08 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 2 Dec 2014 12:35:52 +0100 Subject: [PATCH] Fix stack underflow --- src/game/server/gamecontext.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index a2c410846..f3a7bce4e 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -2524,6 +2524,7 @@ void CGameContext::SendChatResponseAll(const char *pLine, void *pUser) CGameContext *pSelf = (CGameContext *)pUser; static volatile int ReentryGuard = 0; + const char *pLineOrig = pLine; if(ReentryGuard) return; @@ -2532,7 +2533,7 @@ void CGameContext::SendChatResponseAll(const char *pLine, void *pUser) if(*pLine == '[') do pLine++; - while(*(pLine - 2) != ':' && *pLine != 0);//remove the category (e.g. [Console]: No Such Command) + while((pLine - 2 < pLineOrig || *(pLine - 2) != ':') && *pLine != 0);//remove the category (e.g. [Console]: No Such Command) pSelf->SendChat(-1, CHAT_ALL, pLine); @@ -2547,6 +2548,8 @@ void CGameContext::SendChatResponse(const char *pLine, void *pUser) if(ClientID < 0 || ClientID >= MAX_CLIENTS) return; + const char *pLineOrig = pLine; + static volatile int ReentryGuard = 0; if(ReentryGuard) @@ -2556,7 +2559,7 @@ void CGameContext::SendChatResponse(const char *pLine, void *pUser) if(*pLine == '[') do pLine++; - while(*(pLine - 2) != ':' && *pLine != 0); // remove the category (e.g. [Console]: No Such Command) + while((pLine - 2 < pLineOrig || *(pLine - 2) != ':') && *pLine != 0); // remove the category (e.g. [Console]: No Such Command) pSelf->SendChatTarget(ClientID, pLine);