[evolution-data-server] imapx: Ensure imapx_stream_fill() sets the error on zero-sized read.



commit d659ce98abc4832825c849913718d5edc84c4054
Author: David Woodhouse <David Woodhouse intel com>
Date:   Mon Jul 12 12:46:01 2010 +0100

    imapx: Ensure imapx_stream_fill() sets the error on zero-sized read.
    
    We treat an empty read as an error, since we should never be here unless
    we're either in the middle of reading a response, or poll() says the fd
    is readable. Before commit 46938c348 (the conversion to GError), we'd set
    a generic 'IO Error' exception in camel_imapx_stream_token() when
    imapx_stream_fill() returned -1 to indicate an error. But now we don't
    do that any more, so imapx_stream_fill() needs to reliably set the GError.
    
    Otherwise we end up in an endless loop in imapx_step().

 camel/providers/imapx/camel-imapx-stream.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index d1bd9b3..f3ed03a 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -62,6 +62,13 @@ imapx_stream_fill (CamelIMAPXStream *is,
 			return is->end - is->ptr;
 		} else {
 			io(printf("camel_imapx_read: -1\n"));
+			/* If returning zero, camel_stream_read() doesn't consider
+			   that to be an error. But we do -- we should only be here
+			   if we *know* there are data to receive. So set the error
+			   accordingly */
+			if (!left)
+				g_set_error(error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+					    _("Source stream returned no data"));
 			return -1;
 		}
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]