RSPAMD_RECV_STATE_PARSE_IP,
RSPAMD_RECV_STATE_SKIP_SPACES,
RSPAMD_RECV_STATE_ERROR
- } state = RSPAMD_RECV_STATE_INIT,
- next_state = RSPAMD_RECV_STATE_INIT;
+ } state = RSPAMD_RECV_STATE_INIT, next_state = RSPAMD_RECV_STATE_INIT;
gboolean is_exim = FALSE;
line = rh->decoded;
struct mime_text_part *part)
{
struct sb_stemmer *stem = NULL;
- rspamd_fstring_t *w;
+ rspamd_ftok_t *w;
const guchar *r;
gchar *temp_word;
guint i, nlen;
if (tmp) {
for (i = 0; i < tmp->len; i ++) {
- w = &g_array_index (tmp, rspamd_fstring_t, i);
+ w = &g_array_index (tmp, rspamd_ftok_t, i);
if (stem) {
r = sb_stemmer_stem (stem, w->begin, w->len);
}
if (stem != NULL && r != NULL) {
nlen = strlen (r);
nlen = MIN (nlen, w->len);
- w->begin = rspamd_mempool_alloc (task->task_pool, nlen);
- memcpy (w->begin, r, nlen);
+ temp_word = rspamd_mempool_alloc (task->task_pool, nlen);
+ memcpy (temp_word, r, nlen);
+ w->begin = temp_word;
w->len = nlen;
}
else {
- temp_word = w->begin;
- w->begin = rspamd_mempool_alloc (task->task_pool, w->len);
- memcpy (w->begin, temp_word, w->len);
+ temp_word = rspamd_mempool_alloc (task->task_pool, w->len);
+ memcpy (temp_word, w->begin, w->len);
if (IS_PART_UTF (part)) {
- rspamd_str_lc_utf8 (w->begin, w->len);
+ rspamd_str_lc_utf8 (temp_word, w->len);
}
else {
- rspamd_str_lc (w->begin, w->len);
+ rspamd_str_lc (temp_word, w->len);
}
+
+ w->begin = temp_word;
}
}
}
guint tw, dw;
tmp = rspamd_mempool_alloc (task->task_pool, sizeof (GByteArray));
- p = task->msg.start;
+ p = task->msg.begin;
len = task->msg.len;
+
/* Skip any space characters to avoid some bad messages to be unparsed */
while (g_ascii_isspace (*p) && len > 0) {
p ++;
gboolean
parse_smtp_command (struct smtp_session *session,
- rspamd_fstring_t *line,
+ rspamd_ftok_t *line,
struct smtp_command **cmd)
{
enum {
SMTP_PARSE_ARGUMENT,
SMTP_PARSE_DONE
} state;
- gchar *p, *c, ch, cmd_buf[4];
+ const gchar *p, *c;
+ gchar ch, cmd_buf[4];
guint i;
- rspamd_fstring_t *arg = NULL;
+ rspamd_ftok_t *arg = NULL;
struct smtp_command *pcmd;
if (line->len == 0) {
}
arg->len = p - c;
arg->begin = rspamd_mempool_alloc (session->pool, arg->len);
- memcpy (arg->begin, c, arg->len);
+ memcpy ((gchar *)arg->begin, c, arg->len);
pcmd->args = g_list_prepend (pcmd->args, arg);
+
if (ch == ' ' || ch == ':') {
state = SMTP_PARSE_SPACES;
}
}
static gboolean
-check_smtp_path (rspamd_fstring_t *path)
+check_smtp_path (rspamd_ftok_t *path)
{
guint i;
- gchar *p;
+ const gchar *p;
p = path->begin;
if (*p != '<' || path->len < 2) {
gboolean
parse_smtp_helo (struct smtp_session *session, struct smtp_command *cmd)
{
- rspamd_fstring_t *arg;
+ rspamd_ftok_t *arg;
if (cmd->args == NULL) {
session->error = SMTP_ERROR_BAD_ARGUMENTS;
gboolean
parse_smtp_from (struct smtp_session *session, struct smtp_command *cmd)
{
- rspamd_fstring_t *arg;
+ rspamd_ftok_t *arg;
GList *cur = cmd->args;
if (cmd->args == NULL) {
gboolean
parse_smtp_rcpt (struct smtp_session *session, struct smtp_command *cmd)
{
- rspamd_fstring_t *arg;
+ rspamd_ftok_t *arg;
GList *cur = cmd->args;
if (cmd->args == NULL) {
/* Return -1 if there are some error, 1 if all is ok and 0 in case of incomplete reply */
static gint
-check_smtp_ustream_reply (rspamd_fstring_t *in, gchar success_code)
+check_smtp_ustream_reply (rspamd_ftok_t *in, gchar success_code)
{
- gchar *p;
+ const gchar *p;
/* Check for 250 at the begin of line */
if (in->len >= sizeof ("220 ") - 1) {
{
GList *cur = args;
size_t r = 0;
- rspamd_fstring_t *arg;
+ rspamd_ftok_t *arg;
while (cur && r < buflen - 3) {
arg = cur->data;
}
gboolean
-smtp_upstream_read_socket (rspamd_fstring_t * in, void *arg)
+smtp_upstream_read_socket (rspamd_ftok_t * in, void *arg)
{
struct smtp_session *session = arg;
gchar outbuf[BUFSIZ];
#define MAX_SMTP_UPSTREAMS 128
+enum smtp_command_type {
+ SMTP_COMMAND_HELO = 0,
+ SMTP_COMMAND_EHLO,
+ SMTP_COMMAND_QUIT,
+ SMTP_COMMAND_NOOP,
+ SMTP_COMMAND_MAIL,
+ SMTP_COMMAND_RCPT,
+ SMTP_COMMAND_RSET,
+ SMTP_COMMAND_DATA,
+ SMTP_COMMAND_VRFY,
+ SMTP_COMMAND_EXPN,
+ SMTP_COMMAND_HELP
+};
struct smtp_command {
- enum {
- SMTP_COMMAND_HELO,
- SMTP_COMMAND_EHLO,
- SMTP_COMMAND_QUIT,
- SMTP_COMMAND_NOOP,
- SMTP_COMMAND_MAIL,
- SMTP_COMMAND_RCPT,
- SMTP_COMMAND_RSET,
- SMTP_COMMAND_DATA,
- SMTP_COMMAND_VRFY,
- SMTP_COMMAND_EXPN,
- SMTP_COMMAND_HELP
- } command;
+ enum smtp_command_type command;
GList *args;
};
* Parse a single SMTP command
*/
gboolean parse_smtp_command (struct smtp_session *session,
- rspamd_fstring_t *line,
+ rspamd_ftok_t *line,
struct smtp_command **cmd);
/*
/*
* Read a line from SMTP upstream
*/
-gboolean smtp_upstream_read_socket (rspamd_fstring_t * in, void *arg);
+gboolean smtp_upstream_read_socket (rspamd_ftok_t * in, void *arg);
/*
* Write to SMTP upstream
if (session) {
if (session->task) {
rspamd_task_free (session->task, FALSE);
- if (session->task->msg.start) {
- munmap (session->task->msg.start, session->task->msg.len);
+ if (session->task->msg.begin) {
+ munmap ((gpointer)session->task->msg.begin,
+ session->task->msg.len);
}
}
if (session->rcpt) {