Tarantool development patches archive
 help / color / mirror / Atom feed
From: Ilya Kosarev <i.kosarev@tarantool.org>
To: imun@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH] lua: assert on lua_gettop() negative return value
Date: Fri, 17 Jul 2020 20:25:29 +0300	[thread overview]
Message-ID: <20200717172529.12608-1-i.kosarev@tarantool.org> (raw)

In case lua_gettop() called from encode_lua_call() returns negative
value, we will segfault in iproto_reply_error() with empty diag, as far
as it is unexpected error path not covered with diagnostics. Thus
corresponding sane check with assert is introduced.

Closes #4649
---
Branch: https://github.com/tarantool/tarantool/tree/i.kosarev/gh-4649-sane-check-on-lua_gettop
Issue: https://github.com/tarantool/tarantool/issues/4649

@ChangeLog:
 * Raise assert on lua_gettop() negative return value (gh-4649).

 src/box/lua/call.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/box/lua/call.c b/src/box/lua/call.c
index ca871e077..75634de5b 100644
--- a/src/box/lua/call.c
+++ b/src/box/lua/call.c
@@ -361,6 +361,7 @@ encode_lua_call(lua_State *L)
 
 	struct luaL_serializer *cfg = luaL_msgpack_default;
 	int size = lua_gettop(port->L);
+	assert(size >= 0);
 	for (int i = 1; i <= size; ++i)
 		luamp_encode(port->L, cfg, &stream, i);
 	port->size = size;
-- 
2.17.1

             reply	other threads:[~2020-07-17 17:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 17:25 Ilya Kosarev [this message]
2020-07-20 10:50 ` Nikita Pettik
2020-07-21 11:05   ` Ilya Kosarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717172529.12608-1-i.kosarev@tarantool.org \
    --to=i.kosarev@tarantool.org \
    --cc=imun@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] lua: assert on lua_gettop() negative return value' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox