From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix assert when MP_EXT received via netbox Date: Mon, 14 Mar 2022 19:17:43 +0300 [thread overview] Message-ID: <20220314161743.GA199674@tarantool.org> (raw) In-Reply-To: <129b7645-1b81-a3b1-c397-a2d878fb59a1@tarantool.org> Hi! Thanks for the review! And sorry for such a late reply. I rewrote this patch and created a PR instead of pasting the changes here: https://github.com/tarantool/tarantool/pull/6922 On Fri, Jan 14, 2022 at 11:36:34PM +0100, Vladislav Shpilevoy wrote: > 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. > Added. > > 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. > True. However, this part is actually wrong, we should throw an error here. Fixed. > > + } > > + *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(). > Thanks, fixed. > 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. Thank you the test! This problem was fixed by fixing 2. I added this test.
prev parent reply other threads:[~2022-03-14 16:17 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-13 9:37 Mergen Imeev via Tarantool-patches 2022-01-14 22:36 ` Vladislav Shpilevoy via Tarantool-patches 2022-03-14 16:17 ` Mergen Imeev via Tarantool-patches [this message]
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=20220314161743.GA199674@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix assert when MP_EXT received via netbox' \ /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