aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-09-23 20:43:39 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-09-23 20:43:39 +0100
commitbc6ec09a56659b35317ac4413a43e3bf47bc0e28 (patch)
tree292469724ba45718942dabbfd45f20e9ce21b004 /contrib
parent3638ca67bdeb181c9ed7b4598933c2655846c280 (diff)
downloadrspamd-bc6ec09a56659b35317ac4413a43e3bf47bc0e28.tar.gz
rspamd-bc6ec09a56659b35317ac4413a43e3bf47bc0e28.zip
[Minor] Fix empty strings import
Issue: #4281
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libucl/lua_ucl.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c
index 88cdf3664..0d934b771 100644
--- a/contrib/libucl/lua_ucl.c
+++ b/contrib/libucl/lua_ucl.c
@@ -484,7 +484,16 @@ ucl_object_lua_fromelt (lua_State *L, int idx, ucl_string_flags_t flags)
str = lua_tolstring (L, idx, &sz);
if (str) {
- obj = ucl_object_fromstring_common (str, sz, flags);
+ /*
+ * ucl_object_fromstring_common has a `logic` to use strlen if sz is zero
+ * which is totally broken...
+ */
+ if (sz > 0) {
+ obj = ucl_object_fromstring_common(str, sz, flags);
+ }
+ else {
+ obj = ucl_object_fromstring_common("", sz, flags);
+ }
}
else {
obj = ucl_object_typed_new (UCL_NULL);
@@ -511,7 +520,12 @@ ucl_object_lua_fromelt (lua_State *L, int idx, ucl_string_flags_t flags)
struct _rspamd_lua_text *t = lua_touserdata (L, idx);
if (t) {
- obj = ucl_object_fromstring_common(t->start, t->len, 0);
+ if (t->len >0) {
+ obj = ucl_object_fromstring_common(t->start, t->len, 0);
+ }
+ else {
+ obj = ucl_object_fromstring_common("", 0, 0);
+ }
/* Binary text */
if (t->flags & (1u << 5u)) {