Skip to content

Commit

Permalink
Correct length check in 'decode_message()'
Browse files Browse the repository at this point in the history
This is need to correct decoding several messages placed
in common buffer (for example, ones read from common response).

Un-read 'len' if message is shotter than read buffer.
  • Loading branch information
Daniil Lemenkov committed Oct 21, 2018
1 parent f0cca9a commit 2529bf4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion connection/scribe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ end

local function decode_message(rbuf)
local len = rbuf:u32be()
if len < rbuf:avail() then return end
if len > rbuf:avail() then
-- Shift pointer back on size of 'len'
rbuf:skip(- ffi.sizeof('uint32_t'))
return
end
local next_rec = rbuf.p.c + len

local version = rbuf:u32be()
Expand Down

0 comments on commit 2529bf4

Please sign in to comment.