dovecot-2.2: Several fixes to handling "istream input line too l...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jan 14 08:01:59 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/19403b3926f9
changeset: 15641:19403b3926f9
user: Timo Sirainen <tss at iki.fi>
date: Mon Jan 14 08:01:47 2013 +0200
description:
Several fixes to handling "istream input line too long" conditions.
diffstat:
src/auth/db-passwd-file.c | 2 +-
src/doveadm/dsync/doveadm-dsync.c | 22 +++++++++++++++++-----
src/doveadm/server-connection.c | 2 +-
src/lib-lda/lmtp-client.c | 5 ++++-
src/plugins/acl/acl-backend-vfile.c | 2 +-
src/plugins/fts/fts-indexer.c | 6 +++++-
src/plugins/fts/fts-parser-script.c | 9 ++++++---
7 files changed, 35 insertions(+), 13 deletions(-)
diffs (133 lines):
diff -r 20a545f932e3 -r 19403b3926f9 src/auth/db-passwd-file.c
--- a/src/auth/db-passwd-file.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/auth/db-passwd-file.c Mon Jan 14 08:01:47 2013 +0200
@@ -197,7 +197,7 @@
hash_table_create(&pw->users, pw->pool, 0, str_hash, strcmp);
start_time = time(NULL);
- input = i_stream_create_fd(pw->fd, 4096, FALSE);
+ input = i_stream_create_fd(pw->fd, (size_t)-1, FALSE);
i_stream_set_return_partial_line(input, TRUE);
while ((line = i_stream_read_next_line(input)) != NULL) {
if (*line == '\0' || *line == ':' || *line == '#')
diff -r 20a545f932e3 -r 19403b3926f9 src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/doveadm/dsync/doveadm-dsync.c Mon Jan 14 08:01:47 2013 +0200
@@ -61,13 +61,25 @@
static void remote_error_input(struct dsync_cmd_context *ctx)
{
+ const unsigned char *data;
+ size_t size;
const char *line;
- while ((line = i_stream_read_next_line(ctx->err_stream)) != NULL)
- fprintf(stderr, "%s\n", line);
-
- if (ctx->err_stream->eof && ctx->io_err != NULL)
- io_remove(&ctx->io_err);
+ switch (i_stream_read(ctx->err_stream)) {
+ case -2:
+ data = i_stream_get_data(ctx->err_stream, &size);
+ fprintf(stderr, "%.*s", (int)size, data);
+ i_stream_skip(ctx->err_stream, size);
+ break;
+ case -1:
+ if (ctx->io_err != NULL)
+ io_remove(&ctx->io_err);
+ break;
+ default:
+ while ((line = i_stream_next_line(ctx->err_stream)) != NULL)
+ fprintf(stderr, "%s\n", line);
+ break;
+ }
}
static void
diff -r 20a545f932e3 -r 19403b3926f9 src/doveadm/server-connection.c
--- a/src/doveadm/server-connection.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/doveadm/server-connection.c Mon Jan 14 08:01:47 2013 +0200
@@ -224,7 +224,7 @@
}
}
- if (i_stream_read(conn->input) == -1) {
+ if (i_stream_read(conn->input) < 0) {
/* disconnected */
server_connection_destroy(&conn);
return;
diff -r 20a545f932e3 -r 19403b3926f9 src/lib-lda/lmtp-client.c
--- a/src/lib-lda/lmtp-client.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/lib-lda/lmtp-client.c Mon Jan 14 08:01:47 2013 +0200
@@ -540,7 +540,10 @@
str_truncate(client->input_multiline, 0);
}
- if (client->input->stream_errno != 0) {
+ if (client->input->stream_errno == ENOBUFS) {
+ lmtp_client_fail(client,
+ "501 5.5.4 Command reply line too long");
+ } else if (client->input->stream_errno != 0) {
errno = client->input->stream_errno;
i_error("lmtp client: read() failed: %m");
lmtp_client_fail(client, ERRSTR_TEMP_REMOTE_FAILURE
diff -r 20a545f932e3 -r 19403b3926f9 src/plugins/acl/acl-backend-vfile.c
--- a/src/plugins/acl/acl-backend-vfile.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/plugins/acl/acl-backend-vfile.c Mon Jan 14 08:01:47 2013 +0200
@@ -505,7 +505,7 @@
if (aclobj->aclobj.backend->debug)
i_debug("acl vfile: reading file %s", path);
- input = i_stream_create_fd(fd, 4096, FALSE);
+ input = i_stream_create_fd(fd, (size_t)-1, FALSE);
i_stream_set_return_partial_line(input, TRUE);
linenum = 1;
while ((line = i_stream_read_next_line(input)) != NULL) {
diff -r 20a545f932e3 -r 19403b3926f9 src/plugins/fts/fts-indexer.c
--- a/src/plugins/fts/fts-indexer.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/plugins/fts/fts-indexer.c Mon Jan 14 08:01:47 2013 +0200
@@ -191,7 +191,11 @@
return 1;
}
}
- if (ctx->input->eof || ctx->input->stream_errno != 0) {
+ if (ctx->input->stream_errno != 0) {
+ i_error("indexer read() failed: %m");
+ return -1;
+ }
+ if (ctx->input->eof) {
i_error("indexer disconnected unexpectedly");
return -1;
}
diff -r 20a545f932e3 -r 19403b3926f9 src/plugins/fts/fts-parser-script.c
--- a/src/plugins/fts/fts-parser-script.c Mon Jan 14 07:57:39 2013 +0200
+++ b/src/plugins/fts/fts-parser-script.c Mon Jan 14 08:01:47 2013 +0200
@@ -70,7 +70,7 @@
struct istream *input;
struct content *content;
bool eof_seen = FALSE;
- int fd;
+ int fd, ret = 0;
fd = script_connect(user, &path);
if (fd == -1)
@@ -99,14 +99,17 @@
content->content_type = args[0];
content->extensions = (const void *)(args+1);
}
- if (!eof_seen) {
+ if (input->stream_errno != 0) {
+ i_error("parser script read() failed: %m");
+ ret = -1;
+ } else if (!eof_seen) {
if (input->v_offset == 0)
i_error("parser script didn't send any data");
else
i_error("parser script didn't send empty EOF line");
}
i_stream_destroy(&input);
- return 0;
+ return ret;
}
static bool script_support_content(struct mail_user *user,
More information about the dovecot-cvs
mailing list