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 377DA6FCBF; Tue, 5 Oct 2021 00:51:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 377DA6FCBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633384305; bh=5qeAfkyynseA4XkwWLu9sKuutpX6AQH2igggp8SWCnA=; 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=RkqakQmCH5uKJpZcxIgteu6m2ZIA6BdDLVugEMee7vCe2DHuLS3qzQhxb9VSe7WrV +8vMBkBMVqnqP6zx2fWC04HcAqfiuwQEzI+njTWvbl36cUM+4UuSYbqBSKKRDvqYE0 UiPsyAkGoQYJROpYROxQlHoekUn2fl9ZrGwOeA3g= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 DD73F6FC87 for ; Tue, 5 Oct 2021 00:51:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DD73F6FC87 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mXVs7-0004O6-2b; Tue, 05 Oct 2021 00:51:43 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <58315c1f-8fca-453f-0378-c451f4154cc9@tarantool.org> Date: Mon, 4 Oct 2021 23:51:42 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.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: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9064ADF4728AA0EE956D43A9B567FDD9A8B13701973EA0578182A05F538085040C106E5FACE7DE556236D73E5F3ED0CF689EB8973179B4B0A4051182ED23E038E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D6964C9E324ABA58EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B100969577675F2D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8BDFA7CC5F7DA497975B98C4EEE8A227A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B2EE5AD8F952D28FBA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C565C1E6824D8037B43847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505C0B97CAE4A76F82F1C34F68C0206C66B X-C1DE0DAB: 0D63561A33F958A5302CBE02FE516C5585FD5EE822062DAA2492A669239841FFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75B7BFB303F1C7DB4D8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349FF8F8245A2FAA7BE5ACE395A37420ED6DE3AC664BDD42E34EAFD4B317B6FDE9B16DA433F4DC00521D7E09C32AA3244C6B3DAF82D490E5C8A5AEB4A8A1FC69035A1673A01BA68E40729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+1ww+tpaZeoFf/w66dJTOA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D8E7824AD601205A1D96B9FA3E648DC843841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 01/16] sql: remove MEM_Zero flag from struct MEM 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 2 comments below. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index 29d713fd0..ff0c461ce 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -1272,11 +1272,19 @@ zeroblobFunc(sql_context * context, int argc, sql_value ** argv) > n = mem_get_int_unsafe(argv[0]); > if (n < 0) > n = 0; > - if (sql_result_zeroblob64(context, n) != 0) { > + if (n > sql_get()->aLimit[SQL_LIMIT_LENGTH]) { > diag_set(ClientError, ER_SQL_EXECUTE, "string or binary string"\ > "is too big"); > context->is_aborted = true; > + return; > + } > + char *str = sqlDbMallocRawNN(sql_get(), n); > + memset(str, 0, n); 1. There is sqlDbMallocZero(). > + if (str == NULL) { > + context->is_aborted = true; > + return; > } > + mem_set_bin_allocated(context->pOut, str, n); > } > > /* > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 5e23c901c..24d6d7dbf 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -1869,8 +1850,6 @@ mem_get_bin(const struct Mem *mem, const char **s) > *s = mem->n > 0 ? mem->z : NULL; > return 0; > } > - if (mem->type != MEM_TYPE_BIN || (mem->flags & MEM_Zero) != 0) > - return -1; 2. If the type is not MEM_TYPE_BIN, you will return garbage. Maybe keep return -1 for other types? > *s = mem->z; > return 0; > }