static gint
dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, int *remain)
{
- guint8 *p = *pos;
+ guint8 *p = *pos, parts;
guint16 type, datalen, txtlen, copied;
gboolean parsed = FALSE;
elt->txt.data = memory_pool_alloc (rep->request->pool, datalen + 1);
/* Now we should compose data from parts */
copied = 0;
- while (copied < datalen) {
+ parts = 0;
+ while (copied + parts < datalen) {
txtlen = *p;
- if (txtlen + copied < datalen) {
+ if (txtlen + copied + parts <= datalen) {
+ parts ++;
memcpy (elt->txt.data + copied, p + 1, txtlen);
copied += txtlen;
p += txtlen + 1;
cmd.value = 0;
memcpy (cmd.hash, session->h->hash_pipe, sizeof (cmd.hash));
cmd.cmd = FUZZY_CHECK;
+ cmd.flag = 0;
if (write (fd, &cmd, sizeof (struct fuzzy_cmd)) == -1) {
goto err;
}
mime_part = cur->data;
if (mime_part->content->len > 0 && mime_part->checksum != NULL) {
/* Construct fake fuzzy hash */
- fake_fuzzy = memory_pool_alloc (task->task_pool, sizeof (fuzzy_hash_t));
- fake_fuzzy->block_size = 0;
+ fake_fuzzy = memory_pool_alloc0 (task->task_pool, sizeof (fuzzy_hash_t));
g_strlcpy (fake_fuzzy->hash_pipe, mime_part->checksum, sizeof (fake_fuzzy->hash_pipe));
register_fuzzy_call (task, fake_fuzzy);
}
if (mime_part->content->len > 0 && mime_part->checksum != NULL) {
/* Construct fake fuzzy hash */
fake_fuzzy.block_size = 0;
+ bzero (fake_fuzzy.hash_pipe, sizeof (fake_fuzzy.hash_pipe));
g_strlcpy (fake_fuzzy.hash_pipe, mime_part->checksum, sizeof (fake_fuzzy.hash_pipe));
if (! register_fuzzy_controller_call (session, task, &fake_fuzzy, cmd, value, flag, saved)) {
/* Cannot write hash */