From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Konstantin Osipov <kostja.osipov@gmail.com>,
tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user
Date: Wed, 6 Nov 2019 17:48:41 +0300 [thread overview]
Message-ID: <b762ec62-dfbd-4860-a5b9-dcc7de9140b2@tarantool.org> (raw)
In-Reply-To: <20191105181552.GK29784@atlas>
Hi! Thanks for the review!
On 05/11/2019 21:15, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [19/11/05 17:57]:
>> +++ b/src/box/user.cc
>> @@ -521,8 +521,9 @@ user_find_by_name(const char *name, uint32_t len)
>> if (schema_find_id(BOX_USER_ID, 2, name, len, &uid) != 0)
>> return NULL;
>> struct user *user = user_by_id(uid);
>> - if (user == NULL || user->def->type != SC_USER) {
>> - diag_set(ClientError, ER_NO_SUCH_USER, tt_cstr(name, len));
>> + if (user == NULL || user->def->type != SC_USER || uid == BOX_ID_NIL) {
>> + diag_set(ClientError, ER_NO_SUCH_USER,
>> + tt_cstr(name, MIN(BOX_INVALID_NAME_MAX, len)));
>> return NULL;
>
> I would not call user_by_id with BOX_ID_NIL, this is not an error
> but it takes an effort to ponder on and realize it's OK to do so.
>
> Otherwise LGTM.
>
>
Hm, you are right. I should not search by an invalid ID. Fixed
on the branch.
============================================================================
diff --git a/src/box/user.cc b/src/box/user.cc
index 03b4b2e3b..e2fd32740 100644
--- a/src/box/user.cc
+++ b/src/box/user.cc
@@ -520,12 +520,14 @@ user_find_by_name(const char *name, uint32_t len)
uint32_t uid;
if (schema_find_id(BOX_USER_ID, 2, name, len, &uid) != 0)
return NULL;
- struct user *user = user_by_id(uid);
- if (user == NULL || user->def->type != SC_USER) {
- diag_set(ClientError, ER_NO_SUCH_USER, tt_cstr(name, len));
- return NULL;
+ if (uid != BOX_ID_NIL) {
+ struct user *user = user_by_id(uid);
+ if (user != NULL && user->def->type == SC_USER)
+ return user;
}
- return user;
+ diag_set(ClientError, ER_NO_SUCH_USER,
+ tt_cstr(name, MIN(BOX_INVALID_NAME_MAX, len)));
+ return NULL;
}
============================================================================
next prev parent reply other threads:[~2019-11-06 14:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 14:59 [Tarantool-patches] [PATCH 0/3] Replication status errno Vladislav Shpilevoy
2019-11-05 14:59 ` [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user Vladislav Shpilevoy
2019-11-05 18:15 ` Konstantin Osipov
2019-11-06 14:48 ` Vladislav Shpilevoy [this message]
2019-11-05 14:59 ` [Tarantool-patches] [PATCH 2/3] error: move errno into an error object Vladislav Shpilevoy
2019-11-05 18:18 ` Konstantin Osipov
2019-11-06 14:49 ` Vladislav Shpilevoy
2019-11-05 14:59 ` [Tarantool-patches] [PATCH 3/3] replication: show errno in replication info Vladislav Shpilevoy
2019-11-05 18:18 ` Konstantin Osipov
2019-11-05 18:13 ` [Tarantool-patches] [PATCH 0/3] Replication status errno Konstantin Osipov
2019-11-21 17:38 ` Kirill Yukhin
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=b762ec62-dfbd-4860-a5b9-dcc7de9140b2@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=kostja.osipov@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user' \
/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