From f429e4f4424b1c9797f49071e280edc6747c8a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 4 Feb 2016 20:44:35 +0100 Subject: [PATCH] IMAP: Fixed stream vs. parse exception handling. * Protocol::HandleNextResponse() will now exit when a stream exception occurs. * This should fix bug #12601. --- .../inbound_protocols/imap/imap_lib/Protocol.cpp | 4 +++- .../inbound_protocols/imap/imap_lib/Response.cpp | 4 ++-- .../inbound_protocols/imap/imap_lib/Response.h | 9 +++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Protocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Protocol.cpp index 73517c5707..61c98c0719 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Protocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Protocol.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015, Haiku Inc. All Rights Reserved. + * Copyright 2010-2016, Haiku Inc. All Rights Reserved. * Copyright 2010 Clemens Zeidler. All rights reserved. * * Distributed under the terms of the MIT License. @@ -355,6 +355,8 @@ Protocol::HandleResponse(Command* command, bigtime_t timeout, } } catch (ParseException& exception) { printf("Error during parsing: %s\n", exception.Message()); + } catch (StreamException& exception) { + return exception.Status(); } if (fOngoingCommands.size() == 0) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.cpp index 76182b8132..81abd61fb6 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2011-2016, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -393,7 +393,7 @@ ParseException::ParseException(const char* format, ...) StreamException::StreamException(status_t status) : - ParseException("Error from stream: %s", status) + fStatus(status) { } diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.h index b37bc9826b..143817100d 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/Response.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2011-2016, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef RESPONSE_H @@ -107,9 +107,14 @@ protected: }; -class StreamException : public ParseException { +class StreamException : public std::exception { public: StreamException(status_t status); + + status_t Status() const { return fStatus; } + +private: + status_t fStatus; };