Browse Source

Adjusted the server message handler to clamp the read size and force read the size of the message instead of free-reading a null-terminated string. Server message packets do not guarantee this behavior.

master
atom0s 7 years ago
parent
commit
0c65a19226
  1. 11
      links.lua

11
links.lua

@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
_addon.author = 'atom0s';
_addon.name = 'links';
_addon.version = '3.0.1';
_addon.version = '3.0.2';
require 'common'
@ -131,8 +131,15 @@ ashita.register_event('incoming_packet', function(id, size, data) @@ -131,8 +131,15 @@ ashita.register_event('incoming_packet', function(id, size, data)
-- 0x004D - Server Message
if (id == 0x004D) then
-- Get the packet message size..
local s = struct.unpack('L', data, 0x14 + 1);
-- Clamp the size to the max packet size..
-- This is needed for DSP since it messes up chat alignment packets..
local ss = math.clamp(s, 1, size - 0x18);
-- Obtain the chat message from the packet..
msg, _ = struct.unpack('s', data, 0x18 + 1);
msg, _ = struct.unpack('c' .. ss, data, 0x18 + 1);
end
-- 0x00CA - Bazaar Message

Loading…
Cancel
Save