Tarantool development patches archive
 help / color / mirror / Atom feed
From: Maria <maria.khaydich@tarantool.org>
To: tarantool-patches@dev.tarantool.org, georgy@tarantool.org
Subject: [Tarantool-patches] [PATCH] Stack use after scope
Date: Sat, 30 Nov 2019 00:36:24 +0300	[thread overview]
Message-ID: <20191129213624.35735-1-maria.khaydich@tarantool.org> (raw)

Json decode method allocated serializer struct on stack and referenced
it after scope.

Thanks to @Korablev77 for the initial investigation.

Closes #4637
---
 third_party/lua-cjson/lua_cjson.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c
index 3d7edbf28..3d25814f3 100644
--- a/third_party/lua-cjson/lua_cjson.c
+++ b/third_party/lua-cjson/lua_cjson.c
@@ -1005,10 +1005,10 @@ static int json_decode(lua_State *l)
                   "expected 1 or 2 arguments");
 
     if (lua_gettop(l) == 2) {
-        struct luaL_serializer user_cfg = *luaL_checkserializer(l);
-        luaL_serializer_parse_options(l, &user_cfg);
+        struct luaL_serializer *user_cfg = luaL_checkserializer(l);
+        luaL_serializer_parse_options(l, user_cfg);
         lua_pop(l, 1);
-        json.cfg = &user_cfg;
+        json.cfg = user_cfg;
     } else {
         json.cfg = luaL_checkserializer(l);
     }
-- 
2.20.1 (Apple Git-117)

             reply	other threads:[~2019-11-29 21:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 21:36 Maria [this message]
2019-11-29 21:40 ` Maria Khaydich
2019-12-03 12:53 ` Nikita Pettik

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=20191129213624.35735-1-maria.khaydich@tarantool.org \
    --to=maria.khaydich@tarantool.org \
    --cc=georgy@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] Stack use after scope' \
    /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