ソースを参照

[CritFix] Fix hyperscan compilation on regexp change

Rspamd could use an incorrect hyperscan database in the case when a
single regexp has been changed. In this case, Rspamd did not recalculate
the cached files causing shifting of regexp IDs. Subsequently, that
caused random regexp to match whilst completely different patterns were
expected.

With this change, Rspamd also takes care about the order of regexps
(by including it in the crypto hash). This change eliminates the issue
and Rspamd can deal with regexps changes correctly.

MFH: true
tags/1.4.0
Vsevolod Stakhov 7年前
コミット
d3d7c4e415
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更10行の追加0行の削除
  1. 10
    0
      src/libserver/re_cache.c

+ 10
- 0
src/libserver/re_cache.c ファイルの表示

} }


/* Update hashes */ /* Update hashes */
/* Id of re class */
rspamd_cryptobox_hash_update (re_class->st, (gpointer) &re_class->id, rspamd_cryptobox_hash_update (re_class->st, (gpointer) &re_class->id,
sizeof (re_class->id)); sizeof (re_class->id));
rspamd_cryptobox_hash_update (&st_global, (gpointer) &re_class->id, rspamd_cryptobox_hash_update (&st_global, (gpointer) &re_class->id,
sizeof (re_class->id)); sizeof (re_class->id));
/* Id of re expression */
rspamd_cryptobox_hash_update (re_class->st, rspamd_regexp_get_id (re), rspamd_cryptobox_hash_update (re_class->st, rspamd_regexp_get_id (re),
rspamd_cryptobox_HASHBYTES); rspamd_cryptobox_HASHBYTES);
rspamd_cryptobox_hash_update (&st_global, rspamd_regexp_get_id (re), rspamd_cryptobox_hash_update (&st_global, rspamd_regexp_get_id (re),
rspamd_cryptobox_HASHBYTES); rspamd_cryptobox_HASHBYTES);
/* PCRE flags */
fl = rspamd_regexp_get_pcre_flags (re); fl = rspamd_regexp_get_pcre_flags (re);
rspamd_cryptobox_hash_update (re_class->st, (const guchar *)&fl, rspamd_cryptobox_hash_update (re_class->st, (const guchar *)&fl,
sizeof (fl)); sizeof (fl));
rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl, rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl,
sizeof (fl)); sizeof (fl));
/* Rspamd flags */
fl = rspamd_regexp_get_flags (re); fl = rspamd_regexp_get_flags (re);
rspamd_cryptobox_hash_update (re_class->st, (const guchar *) &fl, rspamd_cryptobox_hash_update (re_class->st, (const guchar *) &fl,
sizeof (fl)); sizeof (fl));
rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl, rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl,
sizeof (fl)); sizeof (fl));
/* Limit of hits */
fl = rspamd_regexp_get_maxhits (re); fl = rspamd_regexp_get_maxhits (re);
rspamd_cryptobox_hash_update (re_class->st, (const guchar *) &fl, rspamd_cryptobox_hash_update (re_class->st, (const guchar *) &fl,
sizeof (fl)); sizeof (fl));
rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl, rspamd_cryptobox_hash_update (&st_global, (const guchar *) &fl,
sizeof (fl)); sizeof (fl));
/* Numberic order */
rspamd_cryptobox_hash_update (re_class->st, (const guchar *)&i,
sizeof (i));
rspamd_cryptobox_hash_update (&st_global, (const guchar *)&i,
sizeof (i));
} }


rspamd_cryptobox_hash_final (&st_global, hash_out); rspamd_cryptobox_hash_final (&st_global, hash_out);

読み込み中…
キャンセル
保存