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 963776EC60; Wed, 31 Mar 2021 23:25:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 963776EC60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617222324; bh=marDaiXpXnfGvXLn+swDuyHUHFE+5lTE3l03fRPIDfE=; 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=xJPKLK+4m/g4QJw2mOYEt0cD++yJs9qHDEhFY3mfWDgz4EZ0D1WYFpbc1tYbdq1Nm G3KIwzEwVeNkTM6SNZpcAiZ6W3CdQ66UVISqhP93vcCTqL3RvtxXR11a4U8vYrbbss SHPmuzy7OS+x8XWeDjFhIcMlf2BXdk43100CPZYw= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [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 0DA316EC60 for ; Wed, 31 Mar 2021 23:25:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0DA316EC60 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lRhP0-00042e-34; Wed, 31 Mar 2021 23:25:22 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: Date: Wed, 31 Mar 2021 22:25:21 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E32947287414FD1D04A09E656A5F3377C994A182A05F538085040709FEBF43FB7F542C06E84CE9DC8EA41BDD62ADB93BA84590F2FE5812A48122C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E8764B5BC580342EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637329F9579A0E72DCC8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CE99938B3FD79E1DFBF6A947F5B7DCC5DE956DFFE0DC6718DA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE767883B903EA3BAEA9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CF36E64A7E3F8E58117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735C96613F75B7D048DC4224003CC83647689D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831707C1D43F31F1703008EF5BE183B7CB3 X-C1DE0DAB: 0D63561A33F958A581B5DD5649FF92871AC7658ECCCA009C651E4734B6B6F05BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C2E47CA9A56060900F5DE41C1B28FF6B5FF1044A9F5CAFDD4B4D5707FF4130FDA47078F2374A0F251D7E09C32AA3244C95A986759D8EE59E206998ECA3DD201D7101BF96129E4011729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojetunDCtJ20IWPLwRss8J5w== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382226812624E0FAEEA7F3F12E22BFBF847E3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/2] sql: ignore \0 in string passed to C-function 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 30.03.2021 13:21, Mergen Imeev via Tarantool-patches wrote: > Prior to this patch string passed to user-defined C-function from SQL > was cropped in case it contains '\0'. At the same time, it wasn't > cropped if it is passed to the function from BOX. Now it isn't cropped > when passed from SQL. > > Part of #5938 > --- > diff --git a/test/sql-tap/gh-5938-wrong-string-length.c b/test/sql-tap/gh-5938-wrong-string-length.c > new file mode 100644 > index 000000000..96823f049 > --- /dev/null > +++ b/test/sql-tap/gh-5938-wrong-string-length.c > @@ -0,0 +1,42 @@ > +#include 1. We use "" for non-system headers, not <>. > +#include "module.h" > + > +enum > +{ 2. Enums have { on the same line as 'enum'. > + BUF_SIZE = 512, > +}; > + > +int > +ret_str(box_function_ctx_t *ctx, const char *args, const char *args_end) > +{ > + uint32_t arg_count = mp_decode_array(&args); > + if (arg_count != 1) { > + return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s", > + "invalid argument count"); 3. You don't need "%s", you can pass the error message right away. 4. The expression is misaligned. The same for the other box_error_set(). > + } > + if (mp_typeof(*args) != MP_STR) { > + return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s", > + "argument should be string"); > + } > + const char* str; > + uint32_t str_n; > + str = mp_decode_str(&args, &str_n); > + > + uint32_t size = mp_sizeof_array(1) + mp_sizeof_str(str_n); > + if (size > BUF_SIZE) { > + return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s", > + "string is too long"); > + }