summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-28 18:17:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-28 18:17:37 +0100
commit289af2ae8c75b554899154cb289147ea8f99e815 (patch)
treef8e84b9b7100e5d0670ccf7edbd859162a1610d0
parente629bf1721232d76b5f64f809e44f3b69a0309d7 (diff)
downloadrspamd-289af2ae8c75b554899154cb289147ea8f99e815.tar.gz
rspamd-289af2ae8c75b554899154cb289147ea8f99e815.zip
[Minor] Start command parsing implementation (OPTNEG)
-rw-r--r--src/libserver/milter.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 08a700a27..e90d05f3e 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -121,11 +121,25 @@ rspamd_milter_on_protocol_error (struct rspamd_milter_session *session,
g_error_free (err);
}
+#define READ_INT_32(pos, var) do { \
+ memcpy (&(var), (pos), sizeof (var)); \
+ (pos) += sizeof (var); \
+ (var) = ntohl (var); \
+} while (0)
+
static gboolean
rspamd_milter_process_command (struct rspamd_milter_session *session,
struct rspamd_milter_private *priv)
{
GError *err;
+ rspamd_fstring_t *buf;
+ const guchar *pos;
+ guint cmdlen;
+ guint32 version, actions, protocol;
+
+ buf = priv->parser.buf;
+ pos = buf->str + priv->parser.pos;
+ cmdlen = priv->parser.datalen;
switch (priv->parser.cur_cmd) {
case RSPAMD_MILTER_CMD_ABORT:
@@ -152,6 +166,17 @@ rspamd_milter_process_command (struct rspamd_milter_session *session,
case RSPAMD_MILTER_CMD_EOH:
break;
case RSPAMD_MILTER_CMD_OPTNEG:
+ if (cmdlen != sizeof (guint32) * 3) {
+ err = g_error_new (rspamd_milter_quark (), EINVAL, "invalid "
+ "optneg command");
+ rspamd_milter_on_protocol_error (session, priv, err);
+
+ return FALSE;
+ }
+
+ READ_INT_32 (pos, version);
+ READ_INT_32 (pos, actions);
+ READ_INT_32 (pos, protocol);
break;
case RSPAMD_MILTER_CMD_QUIT:
break;