From: Aki Tuomi Date: Fri, 16 Apr 2021 10:19:26 +0000 (+0300) Subject: lib-lua: Fix luaL_error usage X-Git-Tag: 2.3.16~155 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4258a2d8d7a8d7b6aecd52b05566f759c9c13f6b;p=thirdparty%2Fdovecot%2Fcore.git lib-lua: Fix luaL_error usage --- diff --git a/src/auth/db-lua.c b/src/auth/db-lua.c index 9cb3ab1ebf..0ede7f7210 100644 --- a/src/auth/db-lua.c +++ b/src/auth/db-lua.c @@ -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); } diff --git a/src/lib-lua/dlua-script.c b/src/lib-lua/dlua-script.c index 01a14786ed..3cb6e972ed 100644 --- a/src/lib-lua/dlua-script.c +++ b/src/lib-lua/dlua-script.c @@ -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; } diff --git a/src/lib-storage/mailbox-lua.c b/src/lib-storage/mailbox-lua.c index a02587ed02..18e5c1f9db 100644 --- a/src/lib-storage/mailbox-lua.c +++ b/src/lib-storage/mailbox-lua.c @@ -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; }