From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 88A692986F for ; Mon, 10 Sep 2018 09:36:53 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ffETwMjwL72L for ; Mon, 10 Sep 2018 09:36:53 -0400 (EDT) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 41D3E29527 for ; Mon, 10 Sep 2018 09:36:53 -0400 (EDT) From: Serge Petrenko Subject: [tarantool-patches] [PATCH] lua: fix assertion failure after improper box.schema.user:passwd() call Date: Mon, 10 Sep 2018 16:36:43 +0300 Message-Id: <20180910133643.22656-1-sergepetrenko@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Serge Petrenko Calling box.schema.user:passwd() instead of box.schema.user.passwd() leads to lua passing box.schema.user table as first function argument. This case was unhandled in box.schema.user.passwd() function and lead to an assertion failure. Fix this by handling the aforementioned case and add a test. Closes #3659 --- https://github.com/tarantool/tarantool/issues/3659 https://github.com/tarantool/tarantool/tree/sp/gh-3659-assert-in-user-passwd src/box/lua/schema.lua | 2 +- test/box/misc.result | 8 ++++++++ test/box/misc.test.lua | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 540a2a5fd..6b0c1cbb7 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -2025,7 +2025,7 @@ local function chpasswd(uid, new_password) end box.schema.user.passwd = function(name, new_password) - if name == nil then + if name == nil or type(name) == 'table' then box.error(box.error.PROC_LUA, "Usage: box.schema.user.passwd([user,] password)") end if new_password == nil then diff --git a/test/box/misc.result b/test/box/misc.result index 62376754e..6f05df0fa 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -1148,6 +1148,14 @@ s = box.schema.space.create('test', {user="no_such_user"}) --- - error: User 'no_such_user' is not found ... +-- +-- gh-3659 assertion failure on improper call to +-- box.schema.user:passwd() +-- +box.schema.user:passwd() +--- +- error: 'Usage: box.schema.user.passwd([user,] password)' +... -- Too long WAL write warning (gh-2743). s = box.schema.space.create('test') --- diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index d6815645e..79c74ecbb 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -320,6 +320,12 @@ s:drop() -- s = box.schema.space.create('test', {user="no_such_user"}) +-- +-- gh-3659 assertion failure on improper call to +-- box.schema.user:passwd() +-- +box.schema.user:passwd() + -- Too long WAL write warning (gh-2743). s = box.schema.space.create('test') _ = s:create_index('pk') -- 2.15.2 (Apple Git-101.1)