From: Timo Sirainen Date: Tue, 24 Mar 2020 10:07:35 +0000 (+0200) Subject: imap: SETMETADATA - Cleanup istream return value checking X-Git-Tag: 2.3.11.2~513 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=283b40bfc8d6feb941f9da2468a95baa6a75ad38;p=thirdparty%2Fdovecot%2Fcore.git imap: SETMETADATA - Cleanup istream return value checking The old code seems to have worked correctly already, but now it's a bit clearer how it was intended to work. --- diff --git a/src/imap/cmd-setmetadata.c b/src/imap/cmd-setmetadata.c index 6ef287cee1..6f309cde79 100644 --- a/src/imap/cmd-setmetadata.c +++ b/src/imap/cmd-setmetadata.c @@ -129,7 +129,13 @@ cmd_setmetadata_entry_read_stream(struct imap_setmetadata_context *ctx) while ((ret = i_stream_read_more(ctx->input, &data, &size)) > 0) i_stream_skip(ctx->input, size); - if (ctx->input->v_offset == ctx->entry_value_len) { + if (ret < 0) { + if (ctx->input->v_offset != ctx->entry_value_len) { + /* client disconnected */ + i_assert(ctx->input->eof); + return -1; + } + /* finished reading the value */ i_stream_seek(ctx->input, 0); @@ -149,10 +155,6 @@ cmd_setmetadata_entry_read_stream(struct imap_setmetadata_context *ctx) i_stream_unref(&ctx->input); return 1; } - if (ctx->input->eof) { - /* client disconnected */ - return -1; - } return 0; }