aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-24 13:24:17 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-24 13:24:17 +0300
commitc9c29d4163deb873c9d66104639484e3a9ced2b1 (patch)
tree98cf2be3b3a2679ac27bc281b4970ea8bf327922
parenta0320ce847fb75f83e3c060ece2751f3d6684f05 (diff)
downloadrspamd-c9c29d4163deb873c9d66104639484e3a9ced2b1.tar.gz
rspamd-c9c29d4163deb873c9d66104639484e3a9ced2b1.zip
* Use pool allocator for temp strings in headers
-rw-r--r--src/expressions.c2
-rw-r--r--src/message.c19
-rw-r--r--src/message.h2
-rw-r--r--src/plugins/regexp.c4
4 files changed, 14 insertions, 13 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 46a4f17fe..a6b6ec9a1 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -597,7 +597,7 @@ rspamd_header_exists (struct worker_task *task, GList *args)
return FALSE;
}
- headerlist = message_get_header (task->message, (char *)arg->data);
+ headerlist = message_get_header (task->task_pool, task->message, (char *)arg->data);
if (headerlist) {
g_list_free (headerlist);
return TRUE;
diff --git a/src/message.c b/src/message.c
index be470bb65..fb0473b80 100644
--- a/src/message.c
+++ b/src/message.c
@@ -580,7 +580,7 @@ enum {
};
static GList *
-local_message_get_header(GMimeMessage *message, const char *field)
+local_message_get_header(memory_pool_t *pool, GMimeMessage *message, const char *field)
{
GList * gret = NULL;
#ifndef GMIME24
@@ -592,7 +592,7 @@ local_message_get_header(GMimeMessage *message, const char *field)
h = GMIME_OBJECT(message)->headers->headers;
while (h) {
if (h->value && !g_strncasecmp (field, h->name, strlen (field))) {
- gret = g_list_prepend(gret, g_strdup (h->value));
+ gret = g_list_prepend (gret, memory_pool_strdup (pool, h->value));
}
h = h->next;
}
@@ -608,7 +608,7 @@ local_message_get_header(GMimeMessage *message, const char *field)
while (g_mime_header_iter_is_valid (iter)) {
name = g_mime_header_iter_get_name (iter);
if (!g_strncasecmp (field, name, strlen (name))) {
- gret = g_list_prepend (gret, g_strdup (g_mime_header_iter_get_value (iter)));
+ gret = g_list_prepend (gret, memory_pool_strdup (pool, g_mime_header_iter_get_value (iter)));
}
if (!g_mime_header_iter_next (iter)) {
break;
@@ -671,7 +671,7 @@ GET_RECIPIENT_TEMPLATE(bcc, GMIME_RECIPIENT_TYPE_BCC)
/* different declarations for different types of set and get functions */
typedef const char *(*GetFunc) (GMimeMessage *message);
typedef InternetAddressList *(*GetRcptFunc) (GMimeMessage *message, const char *type );
-typedef GList *(*GetListFunc) (GMimeMessage *message, const char *type );
+typedef GList *(*GetListFunc) (memory_pool_t *pool, GMimeMessage *message, const char *type );
typedef void (*SetFunc) (GMimeMessage *message, const char *value);
typedef void (*SetListFunc) (GMimeMessage *message, const char *field, const char *value);
@@ -767,7 +767,7 @@ message_set_header (GMimeMessage *message, const char *field, const char *value)
* You should free the GList list by yourself.
**/
GList *
-message_get_header (GMimeMessage *message, const char *field)
+message_get_header (memory_pool_t *pool, GMimeMessage *message, const char *field)
{
gint i;
char * ret = NULL, *ia_string;
@@ -791,30 +791,31 @@ message_get_header (GMimeMessage *message, const char *field)
while (ia && ia->address) {
ia_string = internet_address_to_string ((InternetAddress *)ia->address, FALSE);
- gret = g_list_append (gret, ia_string);
+ gret = g_list_prepend (gret, ia_string);
ia = ia->next;
}
#else
i = internet_address_list_length (ia);
while (i > 0) {
ia_string = internet_address_to_string (internet_address_list_get_address (ia, i), FALSE);
- gret = g_list_append (gret, ia_string);
+ gret = g_list_prepend (gret, ia_string);
-- i;
}
#endif
break;
case FUNC_LIST:
- gret = (*(fieldfunc[i].getlistfunc))(message, field);
+ gret = (*(fieldfunc[i].getlistfunc))(pool, message, field);
break;
}
break;
}
}
if (gret == NULL && ret != NULL) {
- gret = g_list_prepend (gret, g_strdup (ret));
+ gret = g_list_prepend (gret, memory_pool_strdup (pool, ret));
}
if (fieldfunc[i].functype == FUNC_CHARFREEPTR && ret) {
g_free (ret);
}
+
return gret;
}
diff --git a/src/message.h b/src/message.h
index 7a39c03af..97b82985a 100644
--- a/src/message.h
+++ b/src/message.h
@@ -45,6 +45,6 @@ int process_learn (struct controller_session *session);
GByteArray* get_next_text_part (memory_pool_t *pool, GList *parts, GList **cur);
void message_set_header (GMimeMessage *message, const char *field, const char *value);
-GList* message_get_header (GMimeMessage *message, const char *field);
+GList* message_get_header (memory_pool_t *pool, GMimeMessage *message, const char *field);
#endif
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index c106ae3e5..b1f4b4f15 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -171,7 +171,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task)
return 0;
}
msg_debug ("process_regexp: checking header regexp: %s = /%s/", re->header, re->regexp_text);
- headerlist = message_get_header (task->message, re->header);
+ headerlist = message_get_header (task->task_pool, task->message, re->header);
if (headerlist == NULL) {
return 0;
}
@@ -183,7 +183,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task)
}
cur = headerlist;
while (cur) {
- if (g_regex_match (re->regexp, cur->data, 0, NULL) == TRUE) {
+ if (cur->data && g_regex_match (re->regexp, cur->data, 0, NULL) == TRUE) {
return 1;
}
cur = g_list_next (cur);