Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat text is broken #1819

Open
SamVanheer opened this issue Jul 11, 2017 · 2 comments
Open

Chat text is broken #1819

SamVanheer opened this issue Jul 11, 2017 · 2 comments

Comments

@SamVanheer
Copy link

This update breaks backwards compatibility with older way to fix it:

message_begin(MSG_ALL, get_user_msgid("SayText"));
write_byte(0);
write_string("%s"); // or %s1
write_string(message);
message_end();

Now (in 7561) it prints only " s" or " s1", but in 6153 (release) it worked fully correctly and accurate.
It is used in some plugins, so now they are broken. Also some plugins using "%s1 : %s2" construction.

Ideally, chat fix should only fix the crash ("%s0" infinite loop and "#Spec_Help_Text ..." chat buffer overflow), but not break backward compatibility.

TextMsg is affected too.

The bug with %s0 is located in CLocalizedStringTable::ConstructString. It checks that X in "%sX" is less or equal than the numFormatParameters, but doesn't check that X > 0.
When there is no "%sX" (but just "%s" or something else) in message then the client uses snwprintf. But snwprintf doesn't support the argument count check like ConstructString, so swnprintf can get the garbage from the stack and crash the client. So there should be used custom snwprintf implementation with argument count checking (they can copy code from CLocalizedStringTable::ConstructString and change the part of code with positional %s).

Original report from:
https://forums.alliedmods.net/showpost.php?p=2534523&postcount=70
https://forums.alliedmods.net/showpost.php?p=2534529&postcount=72

@GoRiLliAz
Copy link

+1

@csoyuncu
Copy link

fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants