]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Fix luaL_error usage
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 16 Apr 2021 10:19:26 +0000 (13:19 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 12 May 2021 09:06:46 +0000 (09:06 +0000)
src/auth/db-lua.c
src/lib-lua/dlua-script.c
src/lib-storage/mailbox-lua.c

index 9cb3ab1ebf1960790e18d9e9ba3309b7158cc722..0ede7f7210f68033db16af5b77810e900f79bbba 100644 (file)
@@ -57,7 +57,7 @@ static int auth_request_lua_var_expand(lua_State *L)
        const char *value, *error;
 
        if (auth_request_lua_do_var_expand(req, tpl, &value, &error) < 0) {
-               return luaL_error(L, error);
+               return luaL_error(L, "%s", error);
        } else {
                lua_pushstring(L, value);
        }
@@ -107,7 +107,7 @@ static int auth_request_lua_response_from_template(lua_State *L)
                if (value == NULL) {
                        lua_pushnil(L);
                } else if (auth_request_lua_do_var_expand(req, value, &expanded, &error) < 0) {
-                       return luaL_error(L, error);
+                       return luaL_error(L, "%s", error);
                } else {
                        lua_pushstring(L, expanded);
                }
index 01a14786edd67e861adf6a6d8649e02900383e28..3cb6e972ed9cb351ed591da57fd290379c8bd634 100644 (file)
@@ -76,9 +76,9 @@ static const char *dlua_reader(lua_State *L, void *ctx, size_t *size_r)
        i_stream_skip(script->in, script->last_read);
        if (i_stream_read_more(script->in, &data, size_r) == -1 &&
            script->in->stream_errno != 0) {
-               luaL_error(L, t_strdup_printf("read(%s) failed: %s",
-                                             script->filename,
-                                             i_stream_get_error(script->in)));
+               luaL_error(L, "read(%s) failed: %s",
+                          script->filename,
+                          i_stream_get_error(script->in));
                *size_r = 0;
                return NULL;
        }
index a02587ed0226b562eeae6ad6968adff5b9a54d1f..18e5c1f9db603502e34ebe2760f30498338d2710 100644 (file)
@@ -174,7 +174,7 @@ static int lua_storage_mailbox_status(lua_State *L)
        if (mailbox_get_status(mbox, items, &status) < 0) {
                const char *error = mailbox_get_last_error(mbox, NULL);
                return luaL_error(L, "mailbox_get_status(%s, %u) failed: %s",
-                                 mbox, items, error);
+                                 mailbox_get_vname(mbox), items, error);
        }
        /* returns a table */
        lua_createtable(L, 0, 20);
@@ -272,8 +272,7 @@ static int lua_storage_mailbox_metadata_set(lua_State *L)
        value = lua_tolstring(L, 3, &value_len);
 
        if (lua_storage_mailbox_attribute_set(mbox, key, value, value_len, &error) < 0)
-               return luaL_error(L,
-                                 t_strdup_printf("Cannot set attribute: %s", error));
+               return luaL_error(L, "Cannot set attribute: %s", error);
 
        return 0;
 }
@@ -286,8 +285,7 @@ static int lua_storage_mailbox_metadata_unset(lua_State *L)
        const char *error;
 
        if (lua_storage_mailbox_attribute_set(mbox, key, NULL, 0,  &error) < 0)
-               return luaL_error(L,
-                                 t_strdup_printf("Cannot unset attribute: %s", error));
+               return luaL_error(L, "Cannot unset attribute: %s", error);
 
        return 0;
 }