Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH] lua: fix assertion failure after improper box.schema.user:passwd() call
Date: Fri, 14 Sep 2018 18:17:52 +0300	[thread overview]
Message-ID: <20180914151752.f7f2nwa5dtpu334u@esperanza> (raw)
In-Reply-To: <20180910133643.22656-1-sergepetrenko@tarantool.org>

On Mon, Sep 10, 2018 at 04:36:43PM +0300, Serge Petrenko wrote:
> 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

This isn't a proper fix, because the following command still crashes:

  box.schema.user.passwd(123)

And this one crashes too:

  box.session.su('admin', function(x) return #x end, 123)

Making error messages user-friendly is good, but I think that #3659 is
about invalid usage of luaT_error in lbox_session_su...

  reply	other threads:[~2018-09-14 15:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 13:36 Serge Petrenko
2018-09-14 15:17 ` Vladimir Davydov [this message]
2018-09-17 14:48   ` Serge Petrenko
2018-09-17 15:42     ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180914151752.f7f2nwa5dtpu334u@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH] lua: fix assertion failure after improper box.schema.user:passwd() call' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox