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 7B57E6EC55; Thu, 26 Aug 2021 23:42:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7B57E6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1630010522; bh=yR/5HbRb6YGA0pnYqKug7T6nlTXgg1bD7a3NXkFqNk0=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=NJllhSVzyNibvuTiw7DmJTLmlPpSd0rBtZXQNQsB6UBf1aulN5cP4yj0ND61PgHkd K3ws526KaGYy1vig04cT7Oc2Wm98l42ZWtLtj8CC6x8Q4IISdF/T7UIwTNRxPgNCVJ gFXR2SIOhRbJY77aNv0cO8N3X1Gg8XKVagGFCJ7w= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 CFFF06EC55 for ; Thu, 26 Aug 2021 23:42:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CFFF06EC55 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mJMCH-0005HV-6K; Thu, 26 Aug 2021 23:42:01 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <9f174b3c-31c6-2276-028d-22c6332f42db@tarantool.org> Date: Thu, 26 Aug 2021 22:42:00 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9ECFD080E047A606F56291F8739A291D6182A05F538085040684E601F8F21F3409F6BB1DFAB2500B4DC74D12481A8254E13E38214E58A43EC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73B44982FA5E78411EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372CFCDE0CF3C283B78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D874B6AF06E19686057D5D75E57CF08C21117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A54FDDCF6EDE542E6981459AC73C1F2C89A2B92CFD8E7F9BE1D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA756665624D6DDF07B5410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34181D1E89D5A0B42FD263F660DCAD08FB65875AA696E40D5B1795AF012E584A567AAE4D90B0C1EC241D7E09C32AA3244C33AAD22E4E95C6F182E574FD5580C71A55E75C8D0ED9F6EE729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+bzRAXO2P1TKn03LnN7qZw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DA2F66F21D5AD5356ACE79DDB59CDC7B33841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix a segfault in hex() on receiving zeroblob 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" Thanks for the patch! See 2 comments below. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index c063552d6..2ff368dc7 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -53,6 +53,49 @@ > +/** Implementation of the HEX() SQL built-in function. */ > +static void > +func_hex(struct sql_context *ctx, int argc, struct Mem **argv) > +{ > + assert(argc == 1); > + (void)argc; > + if (argv[0]->type == MEM_TYPE_NULL) > + return mem_set_null(ctx->pOut); > + > + assert(argv[0]->type == MEM_TYPE_BIN && argv[0]->n >= 0); > + assert((argv[0]->flags & MEM_Zero) == 0 || argv[0]->u.nZero >= 0); > + uint32_t size = 2 * argv[0]->n; > + if ((argv[0]->flags & MEM_Zero) != 0) > + size += 2 * argv[0]->u.nZero; > + if (size == 0) > + return mem_set_str0_static(ctx->pOut, ""); > + > + char *str = sqlDbMallocRawNN(sql_get(), size); > + if (str == NULL) { > + ctx->is_aborted = true; > + return; > + } > + for (int i = 0; i < argv[0]->n; ++i) { > + char c = argv[0]->z[i]; > + str[2 * i] = hexdigits[(c >> 4) & 0xf]; > + str[2 * i + 1] = hexdigits[c & 0xf]; > + } > + if ((argv[0]->flags & MEM_Zero) != 0) { > + for (int i = 0; i < argv[0]->u.nZero; ++i) { > + int j = argv[0]->n + i; > + str[2 * j] = '0'; > + str[2 * j + 1] = '0'; 1. The same as for the patch for 2.8 branch. > + } > + } > + mem_set_str_allocated(ctx->pOut, str, size); > +} > @@ -2034,7 +2042,7 @@ static struct sql_func_definition definitions[] = { > {"GROUP_CONCAT", 2, {FIELD_TYPE_VARBINARY, FIELD_TYPE_VARBINARY}, > FIELD_TYPE_VARBINARY, groupConcatStep, groupConcatFinalize}, > > - {"HEX", 1, {FIELD_TYPE_VARBINARY}, FIELD_TYPE_STRING, hexFunc, NULL}, > + {"HEX", 1, {FIELD_TYPE_VARBINARY}, FIELD_TYPE_STRING, func_hex, NULL}, 2. What is the final name pattern? I see among new function names - trim_func - 'func' suffix - sql_func_uuid, sql_func_version - 'sql_func' prefix - sql_builtin_stub - 'sql' prefix - sum_step - no prefixes or suffixes now you add a fifth way: - func_hex - 'func' prefix. I suggest to choose one way to use for all new function names.