name[MAX_NAME_LENGTH]
1 Attachment(s)
Hello everyone.
Does it make sense to MAX_NAME_LENGTH be defined at 32? utf-8 characters use multiple bits. And my plugins crash if the user name contains utf-8 characters... I give a small example. output Test_1: name[MAX_NAME_LENGTH] strlen: 31, name: '🆃🅴🆂🆃_🅴🅼🆂 Test_2: name[128] strlen: 37, name: '🆃🅴🆂🆃_🅴🅼🆂🅸🆃' Test_3: name[MAX_NAME_LENGTH] + remove invalid UTF-8 char strlen: 29, name: '🆃🅴🆂🆃_🅴🅼🆂' result Test_1: Standard use, missing apostroch, plugin crashes Test_2: ok, no overflow protection. Test_3: with overflow protection. what do you think is the best choice to use? |
Re: name[MAX_NAME_LENGTH]
As I recall, it's set to 32 bytes (well... 31 bytes plus nul terminator) because that's the limit in Source games.
|
Re: name[MAX_NAME_LENGTH]
But I think sourcemod works with a longer user name than 32 bytes. (I must test it.)
In any case, the string returned from GetClientName in conjunction with MAX_NAME_LENGTH returns the corrupted string. Here is an example of a user with the name "████████████████████" (strlen = 60) PHP Code:
Code:
L 02/22/2018 - 09:00:58: Query: INSERT INTO test (server, steamid, name) VALUES ('5.196.99.41:27015', '[U:1:XXXXXXXX]', '██████████?); |
Re: name[MAX_NAME_LENGTH]
I'd go with the second as I use this whenever I collect others' names.
Code:
char sPlayerName[128]; |
Re: name[MAX_NAME_LENGTH]
What game are you testing it?
In CS:GO, MAX_PLAYER_NAME_LENGTH in the engine is 128 bytes. However, in all other supported games, it's 32 bytes, which can even causes truncation in the engine itself, before SourceMod gets the name. (It looks like your test plugin is for L4D2). That said, I don't remember if there's any good reason why we didn't increase SM's MAX_NAME_LENGTH to 128, to match CS:GO. |
Re: name[MAX_NAME_LENGTH]
Hi, my plugin is for L4D2.
I tested it, when I changed my name through "SetClientInfo (client, "name", name);" the name was shortened to 32bytes. So setting the variable to 128bytes will not solve my problem. The only solution is to check the player name and remove the last invalid UTF-8 char. It's a shame that it sourcemod does not do it automatically. |
Re: name[MAX_NAME_LENGTH]
I'm still not fully understanding the issue.
What I do know:
|
Re: name[MAX_NAME_LENGTH]
Quote:
Code:
sm version |
Re: name[MAX_NAME_LENGTH]
Steam does not allow me to change my name to something more than 32 bytes.
So I can not test it.. But this problem still exists but is very rare. Specifically, my bug: Code:
L 02/22/2018 - 09:00:58: Query: INSERT INTO test (server, steamid, name) VALUES ('5.196.99.41:27015', '[U:1:XXXXXXXX]', '██████████?); His profile: (name: ████████████████████) https://steamidfinder.com/lookup/76561198013648641/ http://steamcommunity.com/profiles/76561198013648641 |
Re: name[MAX_NAME_LENGTH]
Quote:
Just a heads up, if they are changing their name like that to something you can't do in steam or console then they most likely are cheating to be able to set their name within the game engine. I'd say that's suspicious enough just to perm ban them. Most people using a cheat/exploit like this aren't only stopping at changing their name and are most likely taking advantage of other stuff hacking related. |
Re: name[MAX_NAME_LENGTH]
1 Attachment(s)
I've done a simple plugin to remove the invalid UTF-8 characters from the name and logging. So I'll see how common this phenomenon is.
I look at sourcemod and I see there is something similar but in my case it did not work. https://github.com/alliedmodders/sou...f26de11e9375f4 |
All times are GMT -4. The time now is 21:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.