* [Tarantool-patches] [PATCH] box/console: Fix crash in error message @ 2019-11-08 13:36 Cyrill Gorcunov 2019-11-08 13:54 ` Cyrill Gorcunov 0 siblings, 1 reply; 4+ messages in thread From: Cyrill Gorcunov @ 2019-11-08 13:36 UTC (permalink / raw) To: tml When invalid command passed we should print out the excat value, instead due to typo in 96dbc49d097a96af5273cce2b5663db5917f4ea9 we cause a nil dereference. Reported-by: Mergen Imeev <imeevma@tarantool.org> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- src/box/lua/console.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 52df67465..d4d8ec984 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -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 -- 2.20.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Tarantool-patches] [PATCH] box/console: Fix crash in error message 2019-11-08 13:36 [Tarantool-patches] [PATCH] box/console: Fix crash in error message Cyrill Gorcunov @ 2019-11-08 13:54 ` Cyrill Gorcunov 2019-11-08 21:44 ` Alexander Turenko 0 siblings, 1 reply; 4+ messages in thread From: Cyrill Gorcunov @ 2019-11-08 13:54 UTC (permalink / raw) To: tml The former message has been dropped by tarantool.org receivers, so lets try to resend... --- When invalid command passed we should print out the excat value, instead due to typo in 96dbc49d097a96af5273cce2b5663db5917f4ea9 we cause a nil dereference. Reported-by: Mergen Imeev <imeevma@tarantool.org> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- src/box/lua/console.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 52df67465..d4d8ec984 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -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 -- 2.20.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] box/console: Fix crash in error message 2019-11-08 13:54 ` Cyrill Gorcunov @ 2019-11-08 21:44 ` Alexander Turenko 2019-11-08 21:46 ` Cyrill Gorcunov 0 siblings, 1 reply; 4+ messages in thread From: Alexander Turenko @ 2019-11-08 21:44 UTC (permalink / raw) To: Cyrill Gorcunov; +Cc: tml The patch LGTM. I made minor changes (listed below) and pushed the patch to master and 2.2 (CCed Kirill). Thanks! WBR, Alexander Turenko. On Fri, Nov 08, 2019 at 04:54:16PM +0300, Cyrill Gorcunov wrote: > The former message has been dropped by tarantool.org receivers, > so lets try to resend... > --- > box/console: Fix crash in error message > When invalid command passed we should print out > the excat value, instead due to typo in > 96dbc49d097a96af5273cce2b5663db5917f4ea9 we > cause a nil dereference. I rewrote the message a bit: | 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 96dbc49d097a96af5273cce2b5663db5917f4ea9 | ('box/console: Refactor command handling'). | | Reported-by: Mergen Imeev <imeevma@tarantool.org> | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> | Reviewed-by: Alexander Turenko <alexander.turenko@tarantool.org> > Reported-by: Mergen Imeev <imeevma@tarantool.org> > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> > --- > src/box/lua/console.lua | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua > index 52df67465..d4d8ec984 100644 > --- a/src/box/lua/console.lua > +++ b/src/box/lua/console.lua > @@ -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 > -- > 2.20.1 > Added the test case: | diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua | index 9e8b41b84..d9db5f887 100755 | --- a/test/app-tap/console.test.lua | +++ b/test/app-tap/console.test.lua | @@ -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,19 @@ 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') ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] box/console: Fix crash in error message 2019-11-08 21:44 ` Alexander Turenko @ 2019-11-08 21:46 ` Cyrill Gorcunov 0 siblings, 0 replies; 4+ messages in thread From: Cyrill Gorcunov @ 2019-11-08 21:46 UTC (permalink / raw) To: Alexander Turenko; +Cc: tml On Sat, Nov 09, 2019 at 12:44:58AM +0300, Alexander Turenko wrote: > The patch LGTM. I made minor changes (listed below) and pushed the patch > to master and 2.2 (CCed Kirill). > > Thanks! Great! Thanks a huge! ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-08 21:46 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-11-08 13:36 [Tarantool-patches] [PATCH] box/console: Fix crash in error message Cyrill Gorcunov 2019-11-08 13:54 ` Cyrill Gorcunov 2019-11-08 21:44 ` Alexander Turenko 2019-11-08 21:46 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox