fix(logic): chat length limit logic - #51
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Source engine chat overflow (SayText2) issues in ConnectAnnounce by sanitizing stored/per-user join messages and enforcing a safe length cap when building the final announcement string.
Changes:
- Added
SanitizeClientJoinMessage()and applied it when loading join messages from local KeyValues and SQL (with a lazy “sanitize then persist” migration). - Introduced explicit truncation/skip logic to keep the final SayText2 output under a fixed length budget, with user-facing notices.
- Bumped plugin version to
2.5.6and added aMAX_SAYTEXT2_LENGTHconstant.
Comments suppressed due to low confidence (1)
addons/sourcemod/scripting/ConnectAnnounce.sp:1413
CPrintToChat*treats the first string parameter as a format string. SincesFinalMessageincludes user-controlled content (e.g.,{NAME}fromGetClientNameand potentially join messages), any%sequences can be interpreted as format specifiers and trigger runtime errors or be abused to spam errors. To avoid format-string injection, pass the message as a data parameter (e.g., use a constant format like%sand providesFinalMessageas an argument), and/or ensure all%characters in inserted user content are escaped.
Format(sFinalMessage, sizeof(sFinalMessage), "%s %s", sFinalMessage, sSafeJoinMessage);
}
}
if (sendToAll)
CPrintToChatAll(sFinalMessage);
else
CPrintToChat(client, sFinalMessage);
Added a static boolean to track length error logging for announcements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Summary
What changed
sm_joinmsg).Why
User impact
DLL_MessageEnd: Refusing to send user message SayText2 of 256 bytes to client, user message size limit is 255 bytesTesting