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 28C9C6FC8F; Thu, 25 Mar 2021 00:27:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 28C9C6FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616621229; bh=9sKolbdVK5kHwgmDk5GlXHtBuXsKl/rWK5cDsW1Ui/M=; 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=CUMOeyMwdK8kcPkmjl8ff5nVxr4zadjcJx8HBdVseDH90fYOr76j+PwgI/ONUQPP8 aQRwZinvvKoS5Yyw5ZUBLgLo38WP/aKF1zDfyyXGT0sA8MgZcZrd1Cner+DGo0yBwb yhLQWeKPsRxnb4swXnh5O98+VNKrE9q9r1E483qQ= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 1F9096BD3C for ; Thu, 25 Mar 2021 00:24:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1F9096BD3C Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1lPAzZ-0004ib-4P; Thu, 25 Mar 2021 00:24:41 +0300 To: tarantool-patches@dev.tarantool.org, kyukhin@tarantool.org Date: Wed, 24 Mar 2021 22:24:25 +0100 Message-Id: <8abe8bf4cd3e7ff728d42c3b93d4f5de650f37be.1616620860.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: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9064ADF4728AA0EE9F3698E42D5F8E2CF5ABB710F58BD1CA8182A05F5380850400553D69656198F1663C047FF5D4BA32C3FE6698545C5DCBB5A901864E2FB301A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B9FBA884A7C9B8BAEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063790B55F3E386DB9B28638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C5DD32608FC869F5DFE66DB037E0714C83596A325F69C436BA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3ED8438A78DFE0A9E117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF0EA335BCDFF8BE43BA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B6B97225A968AB36AC76E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B3BBE47FD9DD3FB59A8DF7F3B2552694A2BEBFE083D3B9BA73A03B725D353964BB11811A4A51E3B096D1867E19FE14079BA9C0B312567BB23089D37D7C0E48F6CA18204E546F3947C83C798A30B85E16BC6EABA9B74D0DA47C8A9BA7A39EFB7666BA297DBC24807EA089D37D7C0E48F6C8AA50765F7900637B8F435DEDE9E76EBEFF80C71ABB335746BA297DBC24807EA27F269C8F02392CD6143B1329D1CCA5627F269C8F02392CD5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824AC8B6CDF511875BC4E8F7B195E1C97831148145A0506FFD489BFD3320250DC888 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C5DD32608FC869F5DFE66DB037E0714C83596A325F69C436B9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34806D3522FB05EB39FB28DF9CB7F58F0CFA6041532584665555E8B52F0CC92EDA3094115A18D9EC3D1D7E09C32AA3244C1B456CFE3B3A6C2C904F593561D287DA51E887DA02A9F7BF729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojjqzNotmU+gdnPhORHZSuYA== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110A906815429F9D9603D546B87E11D1700E9D060FE5E2D3E9507784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 13/15] 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 (cherry picked from commit 6b331f7a78aa409ad68ffc8ceb3deb3733a32473) --- src/sio.cc | 2 +- src/sio.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sio.cc b/src/sio.cc index 0ba19346c..a425b8383 100644 --- a/src/sio.cc +++ b/src/sio.cc @@ -81,7 +81,7 @@ sio_socketname(int fd) { /* Preserve errno */ int save_errno = errno; - static __thread char name[2 * SERVICE_NAME_MAXLEN]; + static __thread char name[SERVICE_NAME_MAXLEN]; int rc = sio_socketname_to_buffer(fd, name, sizeof(name)); /* * Could fail only because of a bad format in snprintf, but it is not diff --git a/src/sio.h b/src/sio.h index f728af547..3b91f7eee 100644 --- a/src/sio.h +++ b/src/sio.h @@ -46,7 +46,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, +}; const char * sio_strfaddr(struct sockaddr *addr, socklen_t addrlen); -- 2.24.3 (Apple Git-128)