From 55e53c9e272fe19d1c90ca35d8f59cffece89b9f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 27 Nov 2022 19:44:30 +0000 Subject: [Minor] Check types in ucl `parse_text` method --- contrib/libucl/lua_ucl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c index 0d934b771..c2e39c462 100644 --- a/contrib/libucl/lua_ucl.c +++ b/contrib/libucl/lua_ucl.c @@ -885,7 +885,7 @@ lua_ucl_parser_parse_text (lua_State *L) if (lua_type (L, 2) == LUA_TUSERDATA) { t = lua_touserdata (L, 2); } - else { + else if (lua_type (L, 2) == LUA_TSTRING) { const gchar *s; gsize len; static struct _rspamd_lua_text st_t; @@ -896,6 +896,9 @@ lua_ucl_parser_parse_text (lua_State *L) t = &st_t; } + else { + return luaL_error(L, "invalid argument as input, expected userdata or a string"); + } if (lua_type (L, 3) == LUA_TSTRING) { type = lua_ucl_str_to_parse_type (lua_tostring (L, 3)); -- cgit v1.2.3