diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-16 00:32:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-16 00:32:47 +0000 |
commit | 455dd6e0a7eb8aadc77acc4c37d20313bd42ae90 (patch) | |
tree | 76f6d0a27dc0042ad7a6f30df8988e798592827f /src/libserver/rspamd_control.c | |
parent | 655b2644d90dfec7294f597df469e2ae3c29948a (diff) | |
download | rspamd-455dd6e0a7eb8aadc77acc4c37d20313bd42ae90.tar.gz rspamd-455dd6e0a7eb8aadc77acc4c37d20313bd42ae90.zip |
Fix some border cases in control logic
Diffstat (limited to 'src/libserver/rspamd_control.c')
-rw-r--r-- | src/libserver/rspamd_control.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index b683ac46f..df9746abf 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -543,10 +543,14 @@ rspamd_control_default_worker_handler (gint fd, short what, gpointer ud) r = read (fd, &cmd, sizeof (cmd)); - if (r != sizeof (cmd)) { + if (r == -1) { msg_err ("cannot read request from the control socket: %s", strerror (errno)); } + else if (r < (gint)sizeof (cmd)) { + msg_err ("short read of control command: %d of %d", (gint)r, + (gint)sizeof (cmd)); + } else if ((gint)cmd.type >= 0 && cmd.type < RSPAMD_CONTROL_MAX) { if (cd->handlers[cmd.type].handler) { @@ -557,6 +561,9 @@ rspamd_control_default_worker_handler (gint fd, short what, gpointer ud) rspamd_control_default_cmd_handler (fd, cd, &cmd); } } + else { + msg_err ("unknown command: %d", (gint)cmd.type); + } } void |