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 57FF56ECE3; Sat, 15 Jan 2022 01:36:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 57FF56ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1642199798; bh=phYGW8XpF7rwssKhYgGSzh+wbP0i7intGXrM5yoj7L8=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=udC9qsQP/gsoclbaAaleLJR2rTTLLYMjWrMhohxHGXqw2/EFe8gHCRVsS0dV5serE lKrgaqwWc0+RCQmXumFQhf0281Dp1PcC6QTGLAAhExYYQ/Fdgin40WAn3UX4vytpvi zBVXJtTzQ/O9rDBat+I/wZ1zyH2GsmxLqVdZEnCU= 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 AE1956ECE3 for ; Sat, 15 Jan 2022 01:36:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AE1956ECE3 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1n8VBT-0007SG-TJ; Sat, 15 Jan 2022 01:36:36 +0300 Message-ID: <129b7645-1b81-a3b1-c397-a2d878fb59a1@tarantool.org> Date: Fri, 14 Jan 2022 23:36:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <0985d5f43f0eb85d5a2fdcff90f0b2a21a2ecfe8.1642066322.git.imeevma@gmail.com> In-Reply-To: <0985d5f43f0eb85d5a2fdcff90f0b2a21a2ecfe8.1642066322.git.imeevma@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9CD668969C51240A45842FFE3EF17D9AEE991350EB245CB6F182A05F5380850409FA6E2F46D98E0882939F4BA175CF9674C55A2A67C8BF4ACB09C3B4A95653CBB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A4C4638C9DDF45FCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063748C26B83F2B024408638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80B1DB9B01A9AF9619D966A18FF60835D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B62CFFCC7B69C47339089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5A6BC0D33ED9707C0F6272EBC03281D628AF1BCF413872056D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7540E9CF2C1C1CEBBA410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3444047AE358B40754359BE6050FE27AB8E8DFCB77DD1E28E09BE1049A0D2D30B8DC63A9C3A3B0EF351D7E09C32AA3244CBC8616CE01B913F7B883E194F4C4AEC3B4DF56057A86259F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojieoUMt/u5Lh79EFNTVZC6w== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D6E4A428C5084A506A6448BF802F674AA13841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E25FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix assert when MP_EXT received via netbox 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! See 4 comments below. On 13.01.2022 10:37, imeevma@tarantool.org wrote: > This patch fixes an assertion or segmentation fault when getting the > value of MP_EXT via netbox. > > Closes #6766 > --- > https://github.com/tarantool/tarantool/issues/6766 > https://github.com/tarantool/tarantool/tree/imeevma/gh-6766-fix-assert-when-decoding-mp-ext > > src/box/bind.c | 30 ++++++++++++++++++- > test/sql-tap/engine.cfg | 1 + > .../gh-6766-fix-bind-for-mp-ext.test.lua | 30 +++++++++++++++++++ 1. Lets also add a changelog file. > 3 files changed, 60 insertions(+), 1 deletion(-) > create mode 100755 test/sql-tap/gh-6766-fix-bind-for-mp-ext.test.lua > > diff --git a/src/box/bind.c b/src/box/bind.c > index 441c9f46f..6672d1271 100644 > --- a/src/box/bind.c > +++ b/src/box/bind.c > @@ -99,9 +101,35 @@ sql_bind_decode(struct sql_bind *bind, int i, const char **packet) > case MP_BIN: > bind->s = mp_decode_bin(packet, &bind->bytes); > break; > + case MP_EXT: { > + int8_t ext_type; > + const char *svp = *packet; > + uint32_t size = mp_decode_extl(packet, &ext_type); > + if (ext_type != MP_UUID && ext_type != MP_DECIMAL) { > + bind->s = svp; > + *packet += size; > + bind->bytes = *packet - svp; > + break; 2. It might be better to move this below into 'else' branch after all the type checks. > + } > + *packet = svp; > + if (ext_type == MP_UUID) { > + if (mp_decode_uuid(packet, &bind->uuid) == NULL) { 3. You already decoded the ext header. So you can call uuid_unpack(). Same below with decimal_unpack(). 4. It still might be good to handle unknown MP_EXT values in sql_bind_column or before it. Otherwise you will get a crash on any of them: netbox = require('net.box') msgpack = require('msgpack') box.cfg{listen = 3313} box.schema.user.grant('guest', 'super') str = '\xc7\x00\x0f' val = msgpack.object_from_raw(str) con = netbox.connect(box.cfg.listen) con:execute([[SELECT typeof(?);]], {val}) Assertion failed: (p->ext_type == MP_UUID || p->ext_type == MP_DECIMAL), function sql_bind_column, file /Users/gerold/Work/Repositories/tarantool/src/box/bind.c, line 220. Here I created a value of extension 15, which we don't support.