Skip to content

Commit

Permalink
Merge pull request #4826 from cyrusimap/sync-fix-sieve-length
Browse files Browse the repository at this point in the history
sync_support: duplicate the sieve script
  • Loading branch information
brong committed Mar 1, 2024
2 parents 0829bc5 + f3f1416 commit 54d8b32
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imap/sync_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,14 +1024,20 @@ static int sync_sieve_validate(struct index_record *record,
sieve_script_t *s = NULL;
char *err = NULL;

r = sieve_script_parse_string(NULL,
msg_base + body->header_size, &err, &s);
// XXX: if mmap is a multiple of 4096 bytes, we can read past the
// end of the mmap - the string won't be correctly NULL terminated
char *script = xstrndup(msg_base + body->header_size, msg_len - body->header_size);
r = sieve_script_parse_string(NULL, script, &err, &s);
free(script);
sieve_script_free(&s);

if (r == SIEVE_OK) {
// create the record now to avoid a re-parse in sync_append_copyfile
message_create_record(record, body);
}
else if (err) {
syslog(LOG_ERR, "sieve script parse error uid=%u: %s", record->uid, err);
}
}

if (body) {
Expand Down

0 comments on commit 54d8b32

Please sign in to comment.