}
if (cb->skip_prob > 0) {
- gdouble coin = rspamd_random_double_fast_seed (cb->xoroshiro_state);
+ gdouble coin = rspamd_random_double_fast_seed (&cb->random_seed);
if (coin < cb->skip_prob) {
return;
}
gsize
-lua_url_adjust_skip_prob (gdouble timestamp,
+lua_url_adjust_skip_prob (float timestamp,
guchar digest[16],
struct lua_tree_cb_data *cb,
gsize sz)
/*
* Use task dependent probabilistic seed to ensure that
* consequent task:get_urls return the same list of urls
+ * We use both digest and timestamp here to avoid attack surface
+ * based just on digest.
*/
- memset (cb->xoroshiro_state, 0, sizeof (cb->xoroshiro_state));
- memcpy (&cb->xoroshiro_state[0], ×tamp,
- MIN (sizeof (cb->xoroshiro_state[0]), sizeof (timestamp)));
- memcpy (&cb->xoroshiro_state[1], digest, 16);
+ memcpy(&cb->random_seed, digest, 4);
+ memcpy(((unsigned char *)&cb->random_seed) + 4, ×tamp, 4);
sz = cb->max_urls;
}
gboolean sort;
gsize max_urls;
gdouble skip_prob;
- guint64 xoroshiro_state[4];
+ guint64 random_seed;
};
void lua_tree_url_callback (gpointer key, gpointer value, gpointer ud);
* @param max_urls
* @return
*/
-gsize lua_url_adjust_skip_prob (gdouble timestamp,
+gsize lua_url_adjust_skip_prob (float timestamp,
guchar *digest,
struct lua_tree_cb_data *cb,
gsize sz);