]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: SETMETADATA - Cleanup istream return value checking
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 24 Mar 2020 10:07:35 +0000 (12:07 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Mar 2020 14:29:33 +0000 (14:29 +0000)
The old code seems to have worked correctly already, but now it's a bit
clearer how it was intended to work.

src/imap/cmd-setmetadata.c

index 6ef287cee1128a187cf4f134537a76ef32886c76..6f309cde79fcefbfc203510fbe3a32c488bd2cf0 100644 (file)
@@ -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;
 }