[PATCH v2 1/4] console: forbid arbitrary session type setting

Vladimir Davydov vdavydov.dev at gmail.com
Fri Dec 21 14:17:41 MSK 2018


On Tue, Dec 11, 2018 at 07:10:20PM +0300, Vladislav Shpilevoy wrote:
> @@ -47,22 +47,33 @@ static const char *sessionlib_name = "box.session";
>  
>  /* Create session and pin it to fiber */
>  static int
> -lbox_session_create(struct lua_State *L)
> +lbox_session_create(struct lua_State *L, enum session_type type)
>  {
>  	struct session *session = fiber_get_session(fiber());
>  	if (session == NULL) {
>  		session = session_create_on_demand();
>  		if (session == NULL)
>  			return luaT_error(L);
> -		session->meta.fd = luaL_optinteger(L, 1, -1);
> +		session->meta.fd = lua_tointeger(L, 1);
>  	}
> -	/* If a session already exists, simply reset its type */
> -	session->type = STR2ENUM(session_type, luaL_optstring(L, 2, "console"));
> +	session->type = type;
>  
>  	lua_pushnumber(L, session->id);
>  	return 1;
>  }

If you didn't remove session_vtab registry, you wouldn't be needing this
patch. I don't think that narrowing functionality of an internal
function makes much sense on its own so please drop it if you agree to
leave the registry.



More information about the Tarantool-patches mailing list