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 88FBF6EC56; Sat, 20 Mar 2021 03:45:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 88FBF6EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616201156; bh=glg0TkIfzChwXMCTv+eZtp8Xo75Ghn4XnjLl6JIECvI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PkuQGXAg7B/ILEb5nQdK3b+1PJ3QtdDUHzK0s1jhHGC2bWrOyN5S5dJzqUMBMvCGp D4thN9wsx9lNeK1M2ga7zpUPZun2+UjrRV36JSL5gugTKDIFB+CiYdbo0rg5Z2axbr s943huJhhapyQL1b08G5qwhmlEzn3AscQrTbkPJY= 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 0DFC76F3D0 for ; Sat, 20 Mar 2021 03:42:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0DFC76F3D0 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lNPhe-00076U-PI; Sat, 20 Mar 2021 03:42:55 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Sat, 20 Mar 2021 01:42:36 +0100 Message-Id: <9ab1c358c2fda852d7f241dc7ccd3ca4381017bd.1616200860.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F1DDD90A25A8FA528D0BFD61B598B81272182A05F53808504081DF660315F73A41048C899AB4EBAE0A5B54A460EE3BC46FADB5D20443BD8928 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE716FAD50E497B9C14EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379B0255B5E5688AF88638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C81A23F326053F8271A155B04B81D294A88F6B5251E86A7E2A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7328B01A8D746D8839FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E97D2AE7161E217F117882F4460429728AD0CFFFB425014E868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C2249753C3A5E0A5AB5B7089D37D7C0E48F6CCF19DD082D7633A0E7DDDDC251EA7DABAAAE862A0553A39223F8577A6DFFEA7C831C17AB68599A1243847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148F90DBEB212AEC08F22623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20BD3311767B7455A33C670FD2BA76E82F8 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C81A23F326053F8271A155B04B81D294A88F6B5251E86A7E29C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFF532FBFD8162E58C699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3483E1FCD56FEA62E6950D596AE8E01B68B24275BBA55C6F24566A734B7938136A033FBEC74BAA4F9C1D7E09C32AA3244CCD49426D6303C22BBF9767748DE46A9381560E2432555DBBFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj8xHC0Ak4ylZL/n8yPe8QYQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822F919855E084E4201D43B8FDE6A6E49F93841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 14/16] sio: increase SERVICE_NAME_MAXLEN size 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" It was 32, and couldn't fit long IPv6 and Unix socket addresses. The patch makes it 200 so now it fits any supported addresses family used in the code. Having SERVICE_NAME_MAXLEN valid is necessary to be able to save a complete address string on the stack in the places where the static buffer returned by sio_strfaddr() can't be used safely. For instance, in the code working with Lua due to Lua GC which might be invoked any moment and in a __gc handler could overwrite the static buffer. Needed for #5632 --- src/lib/core/sio.c | 2 +- src/lib/core/sio.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/core/sio.c b/src/lib/core/sio.c index deffee86c..25c34ea59 100644 --- a/src/lib/core/sio.c +++ b/src/lib/core/sio.c @@ -78,7 +78,7 @@ sio_socketname(int fd) { /* Preserve errno */ int save_errno = errno; - int name_size = 2 * SERVICE_NAME_MAXLEN; + int name_size = SERVICE_NAME_MAXLEN; char *name = static_alloc(name_size); int rc = sio_socketname_to_buffer(fd, name, name_size); /* diff --git a/src/lib/core/sio.h b/src/lib/core/sio.h index db2e3281f..4f5a7f6f3 100644 --- a/src/lib/core/sio.h +++ b/src/lib/core/sio.h @@ -52,7 +52,16 @@ extern "C" { #endif /* defined(__cplusplus) */ -enum { SERVICE_NAME_MAXLEN = 32 }; +enum { + /** + * - Unix socket path is 108 bytes max; + * - IP(v4, v6) max string len is 45; + * + * Max result is rounded up just in case the numbers are a bit different + * on various platforms. + */ + SERVICE_NAME_MAXLEN = 200, +}; /** * Check if an errno, returned from a sio function, means a -- 2.24.3 (Apple Git-128)