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

Lua PlayerSendChatMessage() #275

Open
Magnifikator opened this issue Sep 1, 2012 · 6 comments
Open

Lua PlayerSendChatMessage() #275

Magnifikator opened this issue Sep 1, 2012 · 6 comments

Comments

@Magnifikator
Copy link
Contributor

While I was writing a new artikel in wiki for PlayerSendChatMessage() I was trying several parameters.

I have discovered that with some wrong values you can crash either client or server:

LANG_UNIVERSAL = 0
pPlayer:PlayerSendChatMessage(-1 , LANG_UNIVERSAL, "Client crashs, server stays")
LANG_UNIVERSAL = 0
pPlayer:PlayerSendChatMessage(17 , LANG_UNIVERSAL, "Server crashs") 

May to make a check before accept some values ?

@Swarven
Copy link

Swarven commented Sep 2, 2012

Try this maybe: PlayerSendChatMessage(1, 0, "Text")

I had a tough time with this because i was using the arguments like "SendChatMessage"

@Magnifikator
Copy link
Contributor Author

I think you misunderstand me.

I was correcting in the wiki the type values for SendChatMessage()
http://www.arcemu.org/wiki/Lua_SendChatMessage

And I create a new page for PlayerSendChatMessage()
http://www.arcemu.org/wiki/Lua_PlayerSendChatMessage

I tested several type values from here:
http://www.arcemu.org/wiki/Talk:Lua_SendChatMessage

Some are working only for NPC, some only for player, some I havn't tested.

But I have tested -1 (CHAT_MSG_ADDON ) and 17 (CHAT_MSG_CHANNEL ) and the results are crashes.

However this values may are not applicable nor make logical sense they should be checked by the core to prevent crashes either on server side or client side.

Sidenote (joke)
Or you send pPlayer:PlayerSendChatMessage(-1 , 0, "Goodbye") to a cheating player and his client say goodbye to him :-)

BTW:
1 = CHAT_MSG_SAY

@jackpoz
Copy link
Contributor

jackpoz commented Sep 2, 2012

CHAT_MSG_CHANNEL triggers an assert which is not a crash, it's an assertion failed. Still, a Lua script shouldn't trigger any assert.

@ghost
Copy link

ghost commented Oct 3, 2012

LANG_UNIVERSAL = 0
pPlayer:PlayerSendChatMessage(-1 , LANG_UNIVERSAL, "Client crashs, server stays")

This isn't a defined message type, so it'll crash the client.

A little example about what happens when -1 is converted into an unsigned int32:

int i = -1;
UInt32 u = (UInt32) i;
Console.WriteLine("int: " + i + "\nuint32: " + u);
int: -1
uint32: 4294967295
LANG_UNIVERSAL = 0
pPlayer:PlayerSendChatMessage(17 , LANG_UNIVERSAL, "Server crashs")

17 triggers an assert.

CHAT_MSG_CHANNEL = 17;
...
ARCEMU_ASSERT(type != CHAT_MSG_CHANNEL);

Assertion is that the message type isn't 17.


PS:
Oops, last post is from a month ago. Lol.

@ghost
Copy link

ghost commented Oct 4, 2012

@Magnifikator Could you please provide me some Lua scripts to test this?

@Magnifikator
Copy link
Contributor Author

That's my standard script to test Lua code.
Simply type .test into the say console.

local LANG_UNIVERSAL = 0

function Test(event, pPlayer, Message, Type, Language, Misc)

    if ( Message == ".test" ) then

        SendWorldMessage("This is a test.",2)

        pPlayer:PlayerSendChatMessage(-1 , LANG_UNIVERSAL, "Wow Client crashs, server stays")

--  Alternative try this    
--      pPlayer:PlayerSendChatMessage(17 , LANG_UNIVERSAL, "Server crashs") 

        return false

    end

end

RegisterServerHook(SERVER_HOOK_CHAT, "Test")

@ghost
Copy link

ghost commented Dec 20, 2012

If you do check, -1 is an addon message and i tried my own script on the server and it simply crashed the client. Some reason no crash file was created for me to look at. Will post more information about this as i get more!

@ghost
Copy link

ghost commented Apr 30, 2013

Hello there,
I've made a fix again and also I've improved in programming over the last few months. Unfortunately, I currently don't have a testing environment. The only thing I can do to test this is compiling it. Could anyone please test my solution?
https://github.com/Ceterrec/arcemu/tree/SendChatMessage
Commit: 7fe5022

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

No branches or pull requests

3 participants