Skip to content

Commit

Permalink
lib-sieve: Fixed error handling for mail streams.
Browse files Browse the repository at this point in the history
The previous change prompted some futher code review and similar improvements/fixes were applied at various places in the code.
  • Loading branch information
stephanbosch committed May 9, 2016
1 parent a66812a commit 64ac843
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/lib-sieve/cmd-redirect.c
Expand Up @@ -398,12 +398,18 @@ static int act_redirect_send
o_stream_send(output, str_data(hdr), str_len(hdr));
} T_END;

o_stream_send_istream(output, input);
if (input->stream_errno != 0) {
ret = o_stream_send_istream(output, input);

/* blocking i/o required */
i_assert( ret != 0 );

if (ret < 0 && input->stream_errno != 0) {
sieve_result_critical(aenv,
"redirect action: failed to read input message",
"redirect action: failed to read message stream: %s",
"redirect action: read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
i_stream_unref(&input);
return SIEVE_EXEC_TEMP_FAILURE;
}
i_stream_unref(&input);
Expand Down
3 changes: 2 additions & 1 deletion src/lib-sieve/plugins/notify/ext-notify-common.c
Expand Up @@ -230,7 +230,8 @@ static int cmd_notify_extract_body_text
if ( ret < 0 && input->stream_errno != 0 ) {
sieve_runtime_critical(renv, NULL,
"notify action: failed to read input message",
"notify action: failed to read message stream: %s",
"notify action: read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
return SIEVE_EXEC_TEMP_FAILURE;
}
Expand Down
16 changes: 15 additions & 1 deletion src/lib-sieve/plugins/vnd.dovecot/report/cmd-report.c
Expand Up @@ -593,8 +593,22 @@ static int act_report_send
return sieve_result_mail_error(aenv, msgdata->mail,
"report action: failed to read input message");
}

ret = o_stream_send_istream(output, input);
i_assert(ret != 0);

/* blocking i/o required */
i_assert( ret != 0 );

if ( ret < 0 && input->stream_errno != 0 ) {
/* Error; clean up */
sieve_result_critical(aenv,
"report action: failed to read input message",
"report action: read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
i_stream_unref(&input);
return SIEVE_EXEC_OK;
}
i_stream_unref(&input);

str_truncate(msg, 0);
Expand Down
8 changes: 5 additions & 3 deletions src/lib-sieve/sieve-message.c
Expand Up @@ -1484,7 +1484,8 @@ static int sieve_message_parts_add_missing
if ( input->stream_errno != 0 ) {
sieve_runtime_critical(renv, NULL,
"failed to read input message",
"failed to read message stream: %s",
"read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
return SIEVE_EXEC_TEMP_FAILURE;
}
Expand Down Expand Up @@ -1585,10 +1586,11 @@ int sieve_message_body_get_raw
i_stream_skip(input, size);
}

if ( ret == -1 && input->stream_errno != 0 ) {
if ( ret < 0 && input->stream_errno != 0 ) {
sieve_runtime_critical(renv, NULL,
"failed to read input message",
"failed to read raw message stream: %s",
"read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
return SIEVE_EXEC_TEMP_FAILURE;
}
Expand Down

0 comments on commit 64ac843

Please sign in to comment.