aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-05 22:38:03 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-05 22:38:03 +0100
commit082cd207c15205d17ec51dd6ea09f5e83b5ef2f6 (patch)
treed4f4aa0076774ca9d234f73f6805ef5c9bbd7ebe /src
parent0165ec834d796790d7b476ba315efde669643cac (diff)
downloadrspamd-082cd207c15205d17ec51dd6ea09f5e83b5ef2f6.tar.gz
rspamd-082cd207c15205d17ec51dd6ea09f5e83b5ef2f6.zip
Allow quoted filenames in scan input.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/protocol.c1
-rw-r--r--src/libserver/task.c24
2 files changed, 17 insertions, 8 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 1fedbbb46..a87d8751e 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -262,7 +262,6 @@ rspamd_protocol_handle_url (struct rspamd_task *task,
(p - task->msg.start)) == 0 ||
memcmp (task->msg.start, "path",
(p - task->msg.start)) == 0)) {
- task->flags |= RSPAMD_TASK_FLAG_FILE;
task->msg.start = p + 1;
task->msg.len -= (p - task->msg.start) + 1;
task->flags |= RSPAMD_TASK_FLAG_FILE;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index ebd78b4a9..c2d751dfe 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -259,8 +259,8 @@ rspamd_task_load_message (struct rspamd_task *task,
guint control_len, r;
struct ucl_parser *parser;
ucl_object_t *control_obj;
- gchar filepath[PATH_MAX];
- gint fd;
+ gchar filepath[PATH_MAX], *fp;
+ gint fd, flen;
gpointer map;
struct stat st;
@@ -275,18 +275,28 @@ rspamd_task_load_message (struct rspamd_task *task,
MIN (sizeof (filepath), task->msg.len + 1));
rspamd_unescape_uri (filepath, filepath, r + 1);
+ flen = strlen (filepath);
- if (access (filepath, R_OK) == -1 || stat (filepath, &st) == -1) {
+ if (filepath[0] == '"' && flen > 2) {
+ /* We need to unquote filepath */
+ fp = &filepath[1];
+ fp[flen - 2] = '\0';
+ }
+ else {
+ fp = &filepath[0];
+ }
+
+ if (access (fp, R_OK) == -1 || stat (fp, &st) == -1) {
g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
- "Invalid file (%s): %s", filepath, strerror (errno));
+ "Invalid file (%s): %s", fp, strerror (errno));
return FALSE;
}
- fd = open (filepath, O_RDONLY);
+ fd = open (fp, O_RDONLY);
if (fd == -1) {
g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
- "Cannot open file (%s): %s", filepath, strerror (errno));
+ "Cannot open file (%s): %s", fp, strerror (errno));
return FALSE;
}
@@ -296,7 +306,7 @@ rspamd_task_load_message (struct rspamd_task *task,
if (map == MAP_FAILED) {
close (fd);
g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
- "Cannot mmap file (%s): %s", filepath, strerror (errno));
+ "Cannot mmap file (%s): %s", fp, strerror (errno));
return FALSE;
}