gchar *res_str, *ocharset;
GByteArray *result_array;
- if (task->cfg->raw_mode) {
+ if (task->cfg && task->cfg->raw_mode) {
SET_PART_RAW (text_part);
return part_content;
}
cd = g_mime_part_get_content_disposition (GMIME_PART (mime_part->mime));
if (cd &&
g_ascii_strcasecmp (cd,
- "attachment") == 0 && !task->cfg->check_text_attachements) {
+ "attachment") == 0 && (task->cfg && !task->cfg->check_text_attachements)) {
debug_task ("skip attachments for checking as text parts");
return;
}
if (cd &&
g_ascii_strcasecmp (cd,
GMIME_DISPOSITION_ATTACHMENT) == 0 &&
- !task->cfg->check_text_attachements) {
+ (task->cfg && !task->cfg->check_text_attachements)) {
debug_task ("skip attachments for checking as text parts");
return;
}
ct = g_mime_content_type_new_from_string (ct_cpy);
g_free (ct_cpy);
}
- else if (task->cfg->libs_ctx) {
+ else if (task->cfg && task->cfg->libs_ctx) {
/* Try to predict it by content (slow) */
mb = magic_buffer (task->cfg->libs_ctx->libmagic,
data->data,
message = g_mime_parser_construct_message (parser);
if (message == NULL) {
- if (!task->cfg->allow_raw_input) {
+ if (task->cfg && (!task->cfg->allow_raw_input)) {
msg_err_task ("cannot construct mime from stream");
g_set_error (&task->err,
rspamd_message_quark (),
if (i == 0) {
gboolean need_recv_correction = FALSE;
- if (recv->real_ip == NULL || task->cfg->ignore_received) {
+ if (recv->real_ip == NULL || (task->cfg && task->cfg->ignore_received)) {
need_recv_correction = TRUE;
}
else if (!(task->flags & RSPAMD_TASK_FLAG_NO_IP) && task->from_addr) {
/* Extract data from received header if we were not given IP */
if (task->received->len > 0 && (task->flags & RSPAMD_TASK_FLAG_NO_IP) &&
- !task->cfg->ignore_received) {
+ (task->cfg && !task->cfg->ignore_received)) {
recv = g_ptr_array_index (task->received, 0);
if (recv->real_ip) {
if (!rspamd_parse_inet_address (&task->from_addr,
G_DIR_SEPARATOR, "effective_tld_names.dat");
if (access (fpath->str, R_OK)) {
- msg_warn_config ("url_tld option is not specified but %s is available,"
+ msg_info_config ("url_tld option is not specified but %s is available,"
" therefore this file is assumed as TLD file for URL"
" extraction", fpath->str);
cfg->tld_file = rspamd_mempool_strdup (cfg->cfg_pool, fpath->str);
{
struct rspamd_task *new_task;
- g_assert (cfg != NULL);
-
new_task = g_slice_alloc0 (sizeof (struct rspamd_task));
new_task->worker = worker;
- new_task->cfg = cfg;
- REF_RETAIN (cfg);
- if (cfg->check_all_filters) {
- new_task->flags |= RSPAMD_TASK_FLAG_PASS_ALL;
+ if (cfg) {
+ new_task->cfg = cfg;
+ REF_RETAIN (cfg);
+
+ if (cfg->check_all_filters) {
+ new_task->flags |= RSPAMD_TASK_FLAG_PASS_ALL;
+ }
+
+ new_task->re_rt = rspamd_re_cache_runtime_new (cfg->re_cache);
}
gettimeofday (&new_task->tv, NULL);
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->results);
- new_task->re_rt = rspamd_re_cache_runtime_new (cfg->re_cache);
+
new_task->raw_headers = g_hash_table_new (rspamd_strcase_hash,
rspamd_strcase_equal);
new_task->request_headers = g_hash_table_new_full (rspamd_ftok_icase_hash,
close (task->sock);
}
- rspamd_re_cache_runtime_destroy (task->re_rt);
- REF_RELEASE (task->cfg);
+ if (task->cfg) {
+ rspamd_re_cache_runtime_destroy (task->re_rt);
+ REF_RELEASE (task->cfg);
+ }
rspamd_mempool_delete (task->task_pool);
g_slice_free1 (sizeof (struct rspamd_task), task);