From fcc02b664ed0419ab93df53a4fa3b5ed720ff5d6 Mon Sep 17 00:00:00 2001 From: "Dmitry E. Oboukhov" <unera@debian.org> Date: Wed, 1 Oct 2014 14:35:02 +0400 Subject: [PATCH] net.box checks the first argument in its methods. closes #544 --- src/lua/box_net_box.lua | 10 ++++++++++ test/box/box.net.box.result | 21 +++++++++++++++++++++ test/box/box.net.box.test.lua | 9 +++++++++ 3 files changed, 40 insertions(+) diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index d1dfc63282..9c629d262b 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -391,6 +391,9 @@ local remote_methods = { ping = function(self) + if type(self) ~= 'table' then + box.error(box.error.PROC_LUA, "usage: remote:call(proc_name, ...)") + end if not self:is_connected() then return false end @@ -411,6 +414,10 @@ local remote_methods = { end, call = function(self, proc_name, ...) + if type(self) ~= 'table' then + box.error(box.error.PROC_LUA, "usage: remote:call(proc_name, ...)") + end + proc_name = tostring(proc_name) if not self.console then @@ -1077,6 +1084,9 @@ remote.self = { timeout = function(self) return self end, wait_connected = function(self) return true end, call = function(_box, proc_name, ...) + if type(_box) ~= 'table' then + box.error(box.error.PROC_LUA, "usage: remote:call(proc_name, ...)") + end proc_name = tostring(proc_name) local proc = { package.loaded['box.internal'] .call_loadproc(proc_name) } diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index a5386968a6..0515000fc8 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -582,3 +582,24 @@ remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) --- - error: 'net.box: user is not defined' ... +-- #544 usage for remote[point]method +cn:call('console_test') +--- +- - [] +... +cn.call('console_test') +--- +- error: 'usage: remote:call(proc_name, ...)' +... +cn.ping() +--- +- error: 'usage: remote:call(proc_name, ...)' +... +remote.self:call('console_test') +--- +- [] +... +remote.self.call('console_test') +--- +- error: 'usage: remote:call(proc_name, ...)' +... diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index d7a5770695..97c4f6015a 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -229,3 +229,12 @@ cnc:call('123') remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) +-- #544 usage for remote[point]method +cn:call('console_test') +cn.call('console_test') + +cn.ping() + +remote.self:call('console_test') +remote.self.call('console_test') + -- GitLab