Re: [Dovecot] Dovecot Antispam plugin
Timo,
Christian has reported an error to me on dovecot 1.0.7, where the following code:
199 if (i_stream_read_data(mailstream, &beginning, &size, 5) < 0 || 200 size < 5) { 201 ret = -1; 202 mail_storage_set_error(t->box->storage, 203 ME(NOTPOSSIBLE) 204 "Failed to read mail beginning"); 205 goto failed_to_copy; 206 } 207 208 /* "From "? skip line */ 209 if (memcmp("From ", beginning, 5) == 0) { 210 i_stream_read_next_line(mailstream); 211 } else { 212 if (o_stream_send(outstream, beginning, 5) != 5) { 213 ret = -1; 214 mail_storage_set_error(t->box->storage, 215 ME(NOTPOSSIBLE) 216 "Failed to write line to temp"); 217 goto failed_to_copy; 218 } 219 } 220 221 if (o_stream_send_istream(outstream, mailstream) < 0) { 222 ret = -1; 223 mail_storage_set_error(t->box->storage, 224 ME(NOTPOSSIBLE) 225 "Failed to copy to spool file"); 226 goto failed_to_copy; 227 }
with a mailstream that start with "X-Spam-..." will result in a file stored that starts with "X-SpaX-Spam-...". I've read the above code many times now and tried to find a problem with it, but I don't see it -- could you help us?
johannes
On Mon, 2009-06-15 at 21:03 +0200, Johannes Berg wrote:
Christian has reported an error to me on dovecot 1.0.7, where the following code:
199 if (i_stream_read_data(mailstream, &beginning, &size, 5) < 0 || 200 size < 5) { .. 212 if (o_stream_send(outstream, beginning, 5) != 5) { .. 221 if (o_stream_send_istream(outstream, mailstream) < 0) { .. with a mailstream that start with "X-Spam-..." will result in a file stored that starts with "X-SpaX-Spam-...". I've read the above code many times now and tried to find a problem with it, but I don't see it -- could you help us?
The problem is that the istream API doesn't work the way you expect. Just reading doesn't advance the stream, only calling i_stream_skip() or i_stream_seek() does that (and o_stream_send_istream() internally). So just remove the o_stream_send(beginning) call and it'll work.
On Mon, 2009-06-15 at 15:08 -0400, Timo Sirainen wrote:
On Mon, 2009-06-15 at 21:03 +0200, Johannes Berg wrote:
Christian has reported an error to me on dovecot 1.0.7, where the following code:
199 if (i_stream_read_data(mailstream, &beginning, &size, 5) < 0 || 200 size < 5) { .. 212 if (o_stream_send(outstream, beginning, 5) != 5) { .. 221 if (o_stream_send_istream(outstream, mailstream) < 0) { .. with a mailstream that start with "X-Spam-..." will result in a file stored that starts with "X-SpaX-Spam-...". I've read the above code many times now and tried to find a problem with it, but I don't see it -- could you help us?
The problem is that the istream API doesn't work the way you expect. Just reading doesn't advance the stream, only calling i_stream_skip() or i_stream_seek() does that (and o_stream_send_istream() internally). So just remove the o_stream_send(beginning) call and it'll work.
Aha! I knew I was missing something, thanks. Does i_stream_read_next_line() skip over the line?
johannes
On Mon, 2009-06-15 at 21:11 +0200, Johannes Berg wrote:
The problem is that the istream API doesn't work the way you expect. Just reading doesn't advance the stream, only calling i_stream_skip() or i_stream_seek() does that (and o_stream_send_istream() internally). So just remove the o_stream_send(beginning) call and it'll work.
Aha! I knew I was missing something, thanks. Does i_stream_read_next_line() skip over the line?
Yes, that too. :)
On Mon, 2009-06-15 at 15:15 -0400, Timo Sirainen wrote:
On Mon, 2009-06-15 at 21:11 +0200, Johannes Berg wrote:
The problem is that the istream API doesn't work the way you expect. Just reading doesn't advance the stream, only calling i_stream_skip() or i_stream_seek() does that (and o_stream_send_istream() internally). So just remove the o_stream_send(beginning) call and it'll work.
Aha! I knew I was missing something, thanks. Does i_stream_read_next_line() skip over the line?
Yes, that too. :)
Great, thanks, so I'll just have to remove the else branch to make it work correctly.
johannes
participants (2)
-
Johannes Berg
-
Timo Sirainen