From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6F330445320 for ; Fri, 10 Jul 2020 15:30:01 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id s9so6206880ljm.11 for ; Fri, 10 Jul 2020 05:30:01 -0700 (PDT) Date: Fri, 10 Jul 2020 15:29:58 +0300 From: Cyrill Gorcunov Message-ID: <20200710122958.GF1999@grain> References: <20200710120109.91675-1-roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710120109.91675-1-roman.habibov@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] serilaizer: check for recursive serialization List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov Cc: tarantool-patches@dev.tarantool.org On Fri, Jul 10, 2020 at 03:01:09PM +0300, Roman Khabibov wrote: > luaL_pushcdata(struct lua_State *L, uint32_t ctypeid) > @@ -490,6 +493,11 @@ static int > lua_field_try_serialize(struct lua_State *L, struct luaL_serializer *cfg, > int idx, struct luaL_field *field) > { > + if (idx > SERIALIZER_CRITICAL_RECURSION_DEPTH) { > + diag_set(LuajitError, LUAL_SERIALIZE " generates too deep " > + "recursion"); > + return -1; > + } > if (luaL_getmetafield(L, idx, LUAL_SERIALIZE) == 0) > return 1; Wait. The @idx stands for index in a table as far as I remember, this just happen to hit when you're calling youself recursively but @idx may be > SERIALIZER_CRITICAL_RECURSION_DEPTH for nonrecursive calls as well. Lets CC our Lua's master: Igor. I might be simply wrong.