commit 55e53c9: [Minor] Check types in ucl `parse_text` method

Vsevolod Stakhov vsevolod at rspamd.com
Sun Nov 27 20:07:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-27 19:44:30 +0000
URL: https://github.com/rspamd/rspamd/commit/55e53c9e272fe19d1c90ca35d8f59cffece89b9f

[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));


More information about the Commits mailing list