[Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user

Konstantin Osipov kostja.osipov at gmail.com
Tue Nov 5 21:15:52 MSK 2019


* Vladislav Shpilevoy <v.shpilevoy at 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.


-- 
Konstantin Osipov, Moscow, Russia


More information about the Tarantool-patches mailing list