Skip to content

Commit

Permalink
doveadm sieve plugin: sync: Fixed saving synchronized Sieve script.
Browse files Browse the repository at this point in the history
Assert failure could occur if the input buffer was full.
Also, a small chance existed that not all data would be saved.
  • Loading branch information
stephanbosch committed Oct 6, 2016
1 parent 22f05f1 commit 055537a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/doveadm-sieve/doveadm-sieve-sync.c
Expand Up @@ -326,7 +326,8 @@ sieve_attribute_set_sieve(struct mail_storage *storage,
sieve_storage_save_set_mtime(save_ctx, value->last_change);

ret = 0;
while (i_stream_read(input) > 0) {
while (input->stream_errno == 0 &&
!i_stream_is_eof(input)) {
if (sieve_storage_save_continue(save_ctx) < 0) {
mail_storage_set_critical(storage,
"Failed to save sieve script '%s': %s", scriptname,
Expand All @@ -335,14 +336,14 @@ sieve_attribute_set_sieve(struct mail_storage *storage,
break;
}
}
i_assert(input->eof || ret < 0);
if (input->stream_errno != 0) {
errno = input->stream_errno;
mail_storage_set_critical(storage,
"Saving sieve script: read(%s) failed: %m",
i_stream_get_name(input));
ret = -1;
}
i_assert(input->eof || ret < 0);
if (ret == 0 && sieve_storage_save_finish(save_ctx) < 0) {
mail_storage_set_critical(storage,
"Failed to save sieve script '%s': %s", scriptname,
Expand Down

0 comments on commit 055537a

Please sign in to comment.