Skip to content

Commit 6715455

Browse files
author
Daniil Lemenkov
committed
Correct length check in 'decode_message()'
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 shortter than read buffer.
1 parent f0cca9a commit 6715455

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

connection/scribe.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ end
223223

224224
local function decode_message(rbuf)
225225
local len = rbuf:u32be()
226-
if len < rbuf:avail() then return end
226+
if len > rbuf:avail() then
227+
-- Shift pointer back on size of 'len'
228+
rbuf:skip(- ffi.sizeof('uint32_t'))
229+
return
230+
end
227231
local next_rec = rbuf.p.c + len
228232

229233
local version = rbuf:u32be()

0 commit comments

Comments
 (0)