Skip to content
Snippets Groups Projects
Unverified Commit ada8c97c authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Alexander Turenko
Browse files

box/console: fix abnormal exit after unknown command


When invalid command is passed we should send an error message to a
client. Instead a nil dereference occurs that causes abnormal exit of a
console.

This is the regression from 96dbc49d
('box/console: Refactor command handling').

Reported-by: default avatarMergen Imeev <imeevma@tarantool.org>
Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
parent e3d9d8c9
No related branches found
No related tags found
No related merge requests found
......@@ -323,7 +323,7 @@ local function preprocess(storage, line)
end
if items == nil then
local msg = "Invalid command \\%s. Type \\help for help."
return format(false, msg:format(items[1]))
return format(false, msg:format(line))
end
return operators[items[1]](storage, unpack(items))
end
......
......@@ -21,7 +21,7 @@ local EOL = "\n...\n"
test = tap.test("console")
test:plan(72)
test:plan(73)
-- Start console and connect to it
local server = console.listen(CONSOLE_SOCKET)
......@@ -292,6 +292,20 @@ client:write("box.session.type();\n")
test:is(yaml.decode(client:read(EOL))[1], "console", "session type")
client:close()
--
-- An unknown backslash started command causes abnormal exit of
-- a console.
--
local cmd = '\\unknown_command'
local exp_res = {error = string.format(
'Invalid command %s. Type \\help for help.', cmd)}
client = socket.tcp_connect("unix/", CONSOLE_SOCKET)
client:read(128)
client:write(('%s\n'):format(cmd))
local res = yaml.decode(client:read(EOL))[1]
test:is_deeply(res, exp_res, 'unknown command')
client:close()
server:close()
box.schema.user.drop('test')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment