aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-07 15:58:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-07 15:58:57 +0100
commit58fe582b5d21d10d365954759fcb4c436b557810 (patch)
tree2a89ae956ce033551e16fcd825709251ece8c9b0 /src/libserver
parent1a0025def020ebdcc88f85c5e4a364ce9219de79 (diff)
downloadrspamd-58fe582b5d21d10d365954759fcb4c436b557810.tar.gz
rspamd-58fe582b5d21d10d365954759fcb4c436b557810.zip
Fix the code for updated strings in HTTP library.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/protocol.c28
-rw-r--r--src/libserver/task.c29
-rw-r--r--src/libserver/worker_util.c14
3 files changed, 40 insertions, 31 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 74b229c83..ba2599f5f 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -313,7 +313,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
task->deliver_to);
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -328,7 +328,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
debug_task ("read hostname header, value: %s", task->hostname);
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -336,12 +336,12 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
case 'F':
if (g_ascii_strncasecmp (headern, FROM_HEADER, hlen) == 0) {
if (!rspamd_task_add_sender (task, hv->str)) {
- msg_err_task ("bad from header: '%v'", hv);
+ msg_err_task ("bad from header: '%V'", hv);
validh = FALSE;
}
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -357,7 +357,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
}
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -368,7 +368,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
debug_task ("read queue_id header, value: %s", task->queue_id);
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -376,13 +376,13 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
case 'R':
if (g_ascii_strncasecmp (headern, RCPT_HEADER, hlen) == 0) {
if (!rspamd_task_add_recipient (task, hv->str)) {
- msg_err_task ("bad from header: '%v'", h->value);
+ msg_err_task ("bad from header: '%V'", h->value);
validh = FALSE;
}
- debug_task ("read rcpt header, value: %v", hv);
+ debug_task ("read rcpt header, value: %V", hv);
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -390,14 +390,14 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
case 'I':
if (g_ascii_strncasecmp (headern, IP_ADDR_HEADER, hlen) == 0) {
if (!rspamd_parse_inet_address (&task->from_addr, hv->str)) {
- msg_err_task ("bad ip header: '%v'", hv);
+ msg_err_task ("bad ip header: '%V'", hv);
return FALSE;
}
- debug_task ("read IP header, value: %v", hv);
+ debug_task ("read IP header, value: %V", hv);
has_ip = TRUE;
}
else {
- debug_task ("wrong header: %v", hn);
+ debug_task ("wrong header: %V", hn);
validh = FALSE;
}
break;
@@ -463,7 +463,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
task->message_len = strtoul (hv->str, NULL, 10);
if (task->message_len == 0) {
- msg_err_task ("Invalid message length header: %v", hv);
+ msg_err_task ("Invalid message length header: %V", hv);
validh = FALSE;
}
else {
@@ -475,7 +475,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
}
break;
default:
- debug_task ("unknown header: %v", hn);
+ debug_task ("unknown header: %V", hn);
validh = FALSE;
break;
}
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 6d0eca2a2..907260af2 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -71,15 +71,15 @@ rspamd_task_new (struct rspamd_worker *worker)
new_task->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_gstring_icase_hash,
- rspamd_gstring_icase_equal, rspamd_gstring_free_hard,
- rspamd_gstring_free_hard);
+ new_task->request_headers = g_hash_table_new_full (rspamd_ftok_icase_hash,
+ rspamd_ftok_icase_equal, rspamd_fstring_mapped_ftok_free,
+ rspamd_fstring_mapped_ftok_free);
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->request_headers);
- new_task->reply_headers = g_hash_table_new_full (rspamd_gstring_icase_hash,
- rspamd_gstring_icase_equal, rspamd_gstring_free_hard,
- rspamd_gstring_free_hard);
+ new_task->reply_headers = g_hash_table_new_full (rspamd_ftok_icase_hash,
+ rspamd_ftok_icase_equal, rspamd_fstring_mapped_ftok_free,
+ rspamd_fstring_mapped_ftok_free);
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->reply_headers);
@@ -261,6 +261,7 @@ rspamd_task_load_message (struct rspamd_task *task,
ucl_object_t *control_obj;
gchar filepath[PATH_MAX], *fp;
gint fd, flen;
+ rspamd_ftok_t srch, *tok;
gpointer map;
struct stat st;
@@ -268,11 +269,19 @@ rspamd_task_load_message (struct rspamd_task *task,
rspamd_protocol_handle_headers (task, msg);
}
- if (task->flags & RSPAMD_TASK_FLAG_FILE) {
- g_assert (task->msg.len > 0);
+ srch.begin = "file";
+ srch.len = 4;
+ tok = g_hash_table_lookup (task->request_headers, &srch);
- r = rspamd_strlcpy (filepath, task->msg.begin,
- MIN (sizeof (filepath), task->msg.len + 1));
+ if (tok == NULL) {
+ srch.begin = "path";
+ srch.len = 4;
+ tok = g_hash_table_lookup (task->request_headers, &srch);
+ }
+
+ if (tok) {
+ r = rspamd_strlcpy (filepath, tok->begin,
+ MIN (sizeof (filepath), tok->len + 1));
rspamd_decode_url (filepath, filepath, r + 1);
flen = strlen (filepath);
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index eee200a41..ddd72acb9 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -278,14 +278,14 @@ rspamd_controller_send_error (struct rspamd_http_connection_entry *entry,
msg = rspamd_http_new_message (HTTP_RESPONSE);
va_start (args, error_msg);
- msg->status = g_string_sized_new (128);
- rspamd_vprintf_gstring (msg->status, error_msg, args);
+ msg->status = rspamd_fstring_sized_new (128);
+ rspamd_vprintf_fstring (&msg->status, error_msg, args);
va_end (args);
msg->date = time (NULL);
msg->code = code;
- msg->body = g_string_sized_new (128);
- rspamd_printf_gstring (msg->body, "{\"error\":\"%v\"}", msg->status);
+ msg->body = rspamd_fstring_sized_new (128);
+ rspamd_printf_fstring (&msg->body, "{\"error\":\"%V\"}", msg->status);
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,
@@ -307,7 +307,7 @@ rspamd_controller_send_string (struct rspamd_http_connection_entry *entry,
msg = rspamd_http_new_message (HTTP_RESPONSE);
msg->date = time (NULL);
msg->code = 200;
- msg->body = g_string_new (str);
+ msg->body = rspamd_fstring_new_init (str, strlen (str));
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,
@@ -329,8 +329,8 @@ rspamd_controller_send_ucl (struct rspamd_http_connection_entry *entry,
msg = rspamd_http_new_message (HTTP_RESPONSE);
msg->date = time (NULL);
msg->code = 200;
- msg->body = g_string_sized_new (BUFSIZ);
- rspamd_ucl_emit_gstring (obj, UCL_EMIT_JSON_COMPACT, msg->body);
+ msg->body = rspamd_fstring_sized_new (BUFSIZ);
+ rspamd_ucl_emit_fstring (obj, UCL_EMIT_JSON_COMPACT, &msg->body);
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,