From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C8A586EC55; Tue, 27 Jul 2021 17:14:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C8A586EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627395298; bh=GJRzOJGAO6MPUAJEe2dJtFb9QQJA7+TATMp78HLLYMY=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ln1zrN+7LOWPakTtggH7bPG5roPOzTe+aJDDEiS3FQ1A6vGRRdt75XdNM+QeGfHuZ rkT+DTXNUQdFID+eZWJtwfbXP1GgLYZTHVSkpqKaBHmFyUDS756DfUapVoGpSuvxt8 zJZdRs/QrFlwb/MaFECJU885t51GyHXnQBZEk74Y= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E908C6EC55 for ; Tue, 27 Jul 2021 17:14:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E908C6EC55 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1m8NrF-0007Mm-Cc; Tue, 27 Jul 2021 17:14:57 +0300 Date: Tue, 27 Jul 2021 17:14:56 +0300 To: Cyrill Gorcunov via Tarantool-patches Message-ID: <20210727141456.beydh7oq63vd57ia@esperanza> References: <6c3509125f24f6276be678d6b8f1ac264631d048.1627024646.git.vdavydov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C33D83595CA30D6DC5179D1C9A908C47E5182A05F538085040E37FB6EB41810F95765624CFF70447DD9765E47C44A05F3B632A6FEBC0D23EEC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70A10A23A3B64B805EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E724D704EAF55A818638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D896EE59FA51AC7DAE97DCA028F910707F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B3A703B70628EAD7BA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CB1724D34C644744043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5A7961BE90E124921B429AC6F6F38FD3B1EF3A70AF1C8280BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FA7FF33AA1A4D21C410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3488E5CD2E691F55667411D65E84AA0BD893853BD5966A3CC2DE79F298E159960B331E9CA70EC8978B1D7E09C32AA3244C22AC67C13BFB9C4BF960965A52167901A8CE788DE6831205729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMEANdStWW59XVqZ+U+OC+A== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DC08FB6092AC06CF2B870D389E46BF03D274CEFED1673C562683ABF942079399BFB559BB5D741EB966A65DFF43FF7BE03240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 11/20] net.box: rewrite response decoder in C X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladimir Davydov via Tarantool-patches Reply-To: Vladimir Davydov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Tue, Jul 27, 2021 at 05:07:42PM +0300, Cyrill Gorcunov via Tarantool-patches wrote: > On Fri, Jul 23, 2021 at 02:07:21PM +0300, Vladimir Davydov via Tarantool-patches wrote: > > This patch moves method_decoder table from Lua to C. This is a step > > towards rewriting performance-critical parts of net.box in C. > ... > > +static int > > +netbox_decode_method(struct lua_State *L) > > +{ > > + typedef void (*method_decoder_f)(struct lua_State *L, const char **data, > > + const char *data_end, > > + struct tuple_format *format); > > + static method_decoder_f method_decoder[] = { > > + [NETBOX_PING] = netbox_decode_nil, > > + [NETBOX_CALL_16] = netbox_decode_select, > ... > > + [NETBOX_INJECT] = netbox_decode_table, > > + }; > > + enum netbox_method method = lua_tointeger(L, 1); > > + assert(method < netbox_method_MAX); > > Should not it be runtime testing like > > if (method < 0 || method >= lengthof(method_decoder) || > method_decoder[method] == NULL) { > // Some Lua error thrown > return luaT_error(); > } > > or we've validated this data somewhere already? This is an internal function, which is only called by net_box.lua. All these constants are internal, as well. So I don't think it's worth validating input here or anywhere else in net_box.c.