summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_spf.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-25 13:01:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-25 13:01:23 +0100
commitb36eaf826c1f9e587f189c5e9c58966c726a95c9 (patch)
tree4854cbfc8bf3d5d009e8e8b179f2562f41b82cc1 /src/lua/lua_spf.c
parentcf071c74aa8e7d2975b08a1271902401890c41f7 (diff)
downloadrspamd-b36eaf826c1f9e587f189c5e9c58966c726a95c9.tar.gz
rspamd-b36eaf826c1f9e587f189c5e9c58966c726a95c9.zip
[Minor] Rework to fix issues in Lua API
Found by: coverity scan
Diffstat (limited to 'src/lua/lua_spf.c')
-rw-r--r--src/lua/lua_spf.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/lua/lua_spf.c b/src/lua/lua_spf.c
index 22f1ad2b2..a55b511be 100644
--- a/src/lua/lua_spf.c
+++ b/src/lua/lua_spf.c
@@ -258,9 +258,11 @@ lua_spf_resolve (lua_State * L)
static gint
lua_spf_record_dtor (lua_State *L)
{
- struct spf_resolved *record =
- * (struct spf_resolved **)rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
spf_record_unref (record);
@@ -398,9 +400,10 @@ spf_check_element (lua_State *L, struct spf_resolved *rec, struct spf_addr *addr
static gint
lua_spf_record_check_ip (lua_State *L)
{
- struct spf_resolved *record =
- * (struct spf_resolved **)rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
struct rspamd_lua_ip *ip = NULL;
gint nres = 0;
gboolean need_free_ip = FALSE;
@@ -474,9 +477,10 @@ lua_spf_record_check_ip (lua_State *L)
static gint
lua_spf_record_get_domain (lua_State *L)
{
- struct spf_resolved *record =
- *(struct spf_resolved **) rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
lua_pushstring (L, record->domain);
@@ -495,9 +499,10 @@ lua_spf_record_get_domain (lua_State *L)
static gint
lua_spf_record_get_ttl (lua_State *L)
{
- struct spf_resolved *record =
- *(struct spf_resolved **) rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
lua_pushinteger (L, record->ttl);
@@ -516,9 +521,10 @@ lua_spf_record_get_ttl (lua_State *L)
static gint
lua_spf_record_get_timestamp (lua_State *L)
{
- struct spf_resolved *record =
- *(struct spf_resolved **) rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
lua_pushnumber (L, record->timestamp);
@@ -537,9 +543,10 @@ lua_spf_record_get_timestamp (lua_State *L)
static gint
lua_spf_record_get_digest (lua_State *L)
{
- struct spf_resolved *record =
- *(struct spf_resolved **) rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
gchar hexbuf[64];
@@ -567,9 +574,10 @@ lua_spf_record_get_digest (lua_State *L)
static gint
lua_spf_record_get_elts (lua_State *L)
{
- struct spf_resolved *record =
- *(struct spf_resolved **) rspamd_lua_check_udata (L, 1,
- SPF_RECORD_CLASS);
+ struct spf_resolved *record;
+ RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, 1, SPF_RECORD_CLASS,
+ struct spf_resolved,
+ record);
if (record) {
guint i;