/*** Message interface ***/
LUA_GMIME_BRIDGE_GET (message, get_subject, Message)
- LUA_GMIME_BRIDGE_SET (message, set_subject, Message)
- LUA_GMIME_BRIDGE_GET (message, get_message_id, Message)
- LUA_GMIME_BRIDGE_SET (message, set_message_id, Message)
- LUA_GMIME_BRIDGE_GET (message, get_sender, Message)
- LUA_GMIME_BRIDGE_SET (message, set_sender, Message)
- LUA_GMIME_BRIDGE_GET (message, get_reply_to, Message)
- LUA_GMIME_BRIDGE_SET (message, set_reply_to, Message)
-
- static int
- lua_message_get_header (lua_State * L)
+LUA_GMIME_BRIDGE_SET (message, set_subject, Message)
+LUA_GMIME_BRIDGE_GET (message, get_message_id, Message)
+LUA_GMIME_BRIDGE_SET (message, set_message_id, Message)
+LUA_GMIME_BRIDGE_GET (message, get_sender, Message)
+LUA_GMIME_BRIDGE_SET (message, set_sender, Message)
+LUA_GMIME_BRIDGE_GET (message, get_reply_to, Message)
+LUA_GMIME_BRIDGE_SET (message, set_reply_to, Message)
+
+static int
+lua_message_get_header (lua_State * L)
{
const char *headern;
GMimeMessage *obj = lua_check_message (L);
g_free (cur->data);
cur = g_list_next (cur);
}
- g_free (res);
+ g_list_free (res);
}
else {
lua_pushnil (L);
break;
case FUNC_IA:
ia_list = (*(fieldfunc[i].rcptfunc)) (message, field);
- gret = g_list_alloc ();
ia = ia_list;
#ifndef GMIME24
while (ia && ia->address) {
ia_string = internet_address_to_string ((InternetAddress *) ia->address, FALSE);
- memory_pool_add_destructor (pool, (pool_destruct_func) g_free, ia_string);
+ if (pool != NULL) {
+ memory_pool_add_destructor (pool, (pool_destruct_func) g_free, ia_string);
+ }
gret = g_list_prepend (gret, ia_string);
ia = ia->next;
}
i = internet_address_list_length (ia);
while (i > 0) {
ia_string = internet_address_to_string (internet_address_list_get_address (ia, i), FALSE);
- memory_pool_add_destructor (pool, (pool_destruct_func) g_free, ia_string);
+ if (pool != NULL) {
+ memory_pool_add_destructor (pool, (pool_destruct_func) g_free, ia_string);
+ }
gret = g_list_prepend (gret, ia_string);
--i;
}
local msg = task:get_message()
local smtp_rcpt = task:get_recipients()
local res = false
-
+
if smtp_rcpt then
local mime_rcpt = msg:get_header('To')
local mime_cc = msg:get_header('Cc')
+ local count = 0
+ if mime_rcpt then
+ count = table.maxn(mime_rcpt)
+ end
+ if mime_cc then
+ count = count + table.maxn(mime_cc)
+ end
-- Check recipients count
- if table.maxn(mime_rcpt) + table.maxn(mime_cc) <= table.maxn(smtp_rcpt) then
+ if count <= table.maxn(smtp_rcpt) then
task:insert_result(metric, symbol_rcpt, 1)
else
-- Find pair for each smtp recipient recipient in To or Cc headers
for _,sr in ipairs(smtp_rcpt) do
- for _,mr in ipairs(mime_rcpt) do
- if string.find(mr, sr) then
- res = true
- break
+ if mime_rcpt then
+ for _,mr in ipairs(mime_rcpt) do
+ if string.find(mr, sr) then
+ res = true
+ break
+ end
end
end
- for _,mr in ipairs(mime_cc) do
- if string.find(mr, sr) then
- res = true
- break
+ if mime_cc then
+ for _,mr in ipairs(mime_cc) do
+ if string.find(mr, sr) then
+ res = true
+ break
+ end
end
end
#define SPF_REDIRECT "redirect"
#define SPF_EXP "exp"
+/** SPF limits for avoiding abuse **/
+#define SPF_MAX_NESTING 5
+#define SPF_MAX_DNS_REQUESTS 10
+
/**
* State machine for SPF record:
*
}
static gboolean
-parse_spf_a (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
-{
- struct spf_dns_cb *cb;
-}
-
-static gboolean
-parse_spf_ptr (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
-{
- struct spf_dns_cb *cb;
-
-}
-
-static gboolean
-parse_spf_mx (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ipmask (const char *begin, struct spf_addr *addr)
{
- struct spf_dns_cb *cb;
-
-}
-
-static gboolean
-parse_spf_all (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
-{
- /* All is 0/0 */
- addr->addr = 0;
- addr->mask = 0;
-}
-
-static gboolean
-parse_spf_ip4 (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
-{
- /* ip4:addr[/mask] */
const char *pos;
char ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p;
int state = 0, dots = 0;
else {
addr->mask = 32;
}
-
+
return TRUE;
+
+}
+
+static gboolean
+parse_spf_a (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+{
+ struct spf_dns_cb *cb;
+}
+
+static gboolean
+parse_spf_ptr (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+{
+ struct spf_dns_cb *cb;
+
+}
+
+static gboolean
+parse_spf_mx (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+{
+ struct spf_dns_cb *cb;
+
+}
+
+static gboolean
+parse_spf_all (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+{
+ /* All is 0/0 */
+ addr->addr = 0;
+ addr->mask = 0;
+}
+
+static gboolean
+parse_spf_ip4 (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+{
+ /* ip4:addr[/mask] */
+
+ return parse_spf_ipmask (begin, addr);
}
static gboolean