From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 AD036401A44 for ; Fri, 1 Nov 2019 15:32:49 +0300 (MSK) Date: Fri, 1 Nov 2019 15:32:42 +0300 From: Alexander Turenko Message-ID: <20191101123242.roqd2ayfoopur33o@tkn_work_nb> References: <20190910125838.52181-1-roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190910125838.52181-1-roman.habibov@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] socket: better args handling for connect()/bind() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org Please, rebase your commits on recent master and apply comments below. > socket: better args handling for connect()/bind() I would say about validation rather then handling. > > Check args types in socket.connect() and socket.bind() functions. > 'host' should be a string and 'port' should be a string or a > number. > > Part of #4138 It is better to place this commit before one that closes the issue. > Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4138-getaddrinfo > Issue: https://github.com/tarantool/tarantool/issues/4138 > @@ -1569,7 +1570,8 @@ local function lsocket_connect(host, port) > end > > local function lsocket_bind(host, port, backlog) > - if host == nil or port == nil then > + if type(host) ~= 'string' or (type(port) ~= 'string' and > + type(port) ~= 'number') then I would check backport against 'number' too (if it present). > +socket.connect(127.0.0.1, 3301) > +--- > +- error: '[string "socket.connect(127.0.0.1, 3301) "]:1: malformed number near ''127.0.0.1''' Did you read this error? It is the parsing error from Lua interpreter.