aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-01 15:51:44 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-01 15:52:16 +0100
commit6643ba1ce08dfb96b498d4a809d6013c0648fe92 (patch)
tree7aa60b66bd44ea45e5ad18d1a19a67c8eb07f0cf
parentc07a20097f247302aa5a44c82b40006990141265 (diff)
downloadrspamd-6643ba1ce08dfb96b498d4a809d6013c0648fe92.tar.gz
rspamd-6643ba1ce08dfb96b498d4a809d6013c0648fe92.zip
[Fix] Check min_bytes for images as well
-rw-r--r--src/plugins/fuzzy_check.c76
1 files changed, 42 insertions, 34 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index f5cc61dc6..131500380 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -2349,13 +2349,49 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
image = mime_part->specific.img;
if (image->data->len > 0) {
- if (fuzzy_module_ctx->min_height <= 0 || image->height >=
- fuzzy_module_ctx->min_height) {
- if (fuzzy_module_ctx->min_width <= 0 || image->width >=
- fuzzy_module_ctx->min_width) {
- io = fuzzy_cmd_from_data_part (rule, c, flag, value,
+ /* Check:
+ * - min height
+ * - min width
+ * - min bytes
+ */
+
+ if ((fuzzy_module_ctx->min_height == 0 ||
+ image->height >= fuzzy_module_ctx->min_height) &&
+ (fuzzy_module_ctx->min_width == 0 ||
+ image->width >= fuzzy_module_ctx->min_width) &&
+ (fuzzy_module_ctx->min_bytes <= 0 ||
+ mime_part->parsed_data.len >= fuzzy_module_ctx->min_bytes)) {
+ io = fuzzy_cmd_from_data_part (rule, c, flag, value,
+ task->task_pool,
+ image->parent->digest);
+ if (io) {
+ gboolean skip_existing = FALSE;
+
+ PTR_ARRAY_FOREACH (res, j, cur) {
+ if (memcmp (cur->cmd.digest, io->cmd.digest,
+ sizeof (io->cmd.digest)) == 0) {
+ skip_existing = TRUE;
+ break;
+ }
+ }
+
+ if (!skip_existing) {
+ g_ptr_array_add (res, io);
+ }
+ }
+
+ if (rule->fuzzy_images) {
+ /* Try to normalize image */
+ if (!image->is_normalized) {
+ rspamd_image_normalize (task, image);
+ }
+ }
+
+ if (image->is_normalized) {
+ io = fuzzy_cmd_from_image_part (rule, c, flag,
+ value,
task->task_pool,
- image->parent->digest);
+ image);
if (io) {
gboolean skip_existing = FALSE;
@@ -2371,34 +2407,6 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
g_ptr_array_add (res, io);
}
}
-
- if (rule->fuzzy_images) {
- /* Try to normalize image */
- if (!image->is_normalized) {
- rspamd_image_normalize (task, image);
- }
- }
-
- if (image->is_normalized) {
- io = fuzzy_cmd_from_image_part (rule, c, flag, value,
- task->task_pool,
- image);
- if (io) {
- gboolean skip_existing = FALSE;
-
- PTR_ARRAY_FOREACH (res, j, cur) {
- if (memcmp (cur->cmd.digest, io->cmd.digest,
- sizeof (io->cmd.digest)) == 0) {
- skip_existing = TRUE;
- break;
- }
- }
-
- if (!skip_existing) {
- g_ptr_array_add (res, io);
- }
- }
- }
}
}
}