From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 515DE1FBE7 for ; Mon, 9 Sep 2019 04:03:17 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j3jdCXX94WGg for ; Mon, 9 Sep 2019 04:03:17 -0400 (EDT) Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id AFC311FAAE for ; Mon, 9 Sep 2019 04:03:16 -0400 (EDT) Date: Mon, 9 Sep 2019 11:03:10 +0300 From: Kirill Yukhin Subject: [tarantool-patches] Re: [PATCH v1 1/1] lua_cjson: fix segfault on recursive table encoding Message-ID: <20190909080310.6yajuwo3yikukenb@tarantool.org> References: <2a755460ea51d369b19006f172a989222837f448.1566218225.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2a755460ea51d369b19006f172a989222837f448.1566218225.git.kshcherbatov@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: alexander.turenko@tarantool.org, Kirill Shcherbatov Hello, On 19 Aug 15:37, Kirill Shcherbatov wrote: > The json.encode() used to cause a segfault in case of recursive > table: > tbl = {} > tbl[1] = tbl > json.encode(tbl) > > Library doesn't test whether given object on Lua stack parsed > earlier, because it performs a lightweight in-depth traverse > of Lua stack. However it must stop when encode_max_depth is > reached (by design). > > Tarantool's lua_cjson implementation has a bug introduced during > porting original library: it doesn't handle some corner cases > checking this constant while original code doesn't have such > problem. This patch adopts author's approach to check > encode_max_depth limit. Thanks to handling this constraint > correctly the segfault no longer occurs. > > Closes #4366 > --- > Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-4366-json-recursive-table-segfault > Issue: https://github.com/tarantool/tarantool/issues/4366 I've checked your patch into 1.10, 2.1, 2.2 and master. -- Regards, Kirill Yukhin