mail: IMAP fix recv forever loop on server close connection
When reading stream from closed (by server) TCP socket throw StreamException (not ParseException). This fixes forever loop in Protocol::HandleResponse on server disconnect. This patch fixes #14710 Change-Id: I29e9830b360cb56cb1ef037c0378d64422075c4d Reviewed-on: https://review.haiku-os.org/724 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
81728c84c5
commit
fa94c7d6a5
@@ -450,7 +450,8 @@ Response::~Response()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Response::Parse(BDataIO& stream, LiteralHandler* handler) throw(ParseException)
|
Response::Parse(BDataIO& stream, LiteralHandler* handler)
|
||||||
|
throw(ParseException, StreamException)
|
||||||
{
|
{
|
||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
fLiteralHandler = handler;
|
fLiteralHandler = handler;
|
||||||
@@ -604,7 +605,7 @@ Response::ParseLiteral(ArgumentList& arguments, BDataIO& stream)
|
|||||||
ssize_t bytesRead = stream.Read(buffer + totalRead,
|
ssize_t bytesRead = stream.Read(buffer + totalRead,
|
||||||
size - totalRead);
|
size - totalRead);
|
||||||
if (bytesRead == 0)
|
if (bytesRead == 0)
|
||||||
throw ParseException("Unexpected end of literal");
|
throw StreamException(B_IO_ERROR);
|
||||||
if (bytesRead < 0)
|
if (bytesRead < 0)
|
||||||
throw StreamException(bytesRead);
|
throw StreamException(bytesRead);
|
||||||
|
|
||||||
@@ -706,7 +707,7 @@ Response::Read(BDataIO& stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bytesRead == 0)
|
if (bytesRead == 0)
|
||||||
throw ParseException("Unexpected end of stream");
|
throw StreamException(B_IO_ERROR);
|
||||||
|
|
||||||
throw StreamException(bytesRead);
|
throw StreamException(bytesRead);
|
||||||
}
|
}
|
||||||
@@ -721,7 +722,7 @@ Response::_SkipLiteral(BDataIO& stream, size_t size)
|
|||||||
size_t toRead = std::min(sizeof(buffer), size - totalRead);
|
size_t toRead = std::min(sizeof(buffer), size - totalRead);
|
||||||
ssize_t bytesRead = stream.Read(buffer, toRead);
|
ssize_t bytesRead = stream.Read(buffer, toRead);
|
||||||
if (bytesRead == 0)
|
if (bytesRead == 0)
|
||||||
throw ParseException("Unexpected end of literal");
|
throw StreamException(B_IO_ERROR);
|
||||||
if (bytesRead < 0)
|
if (bytesRead < 0)
|
||||||
throw StreamException(bytesRead);
|
throw StreamException(bytesRead);
|
||||||
|
|
||||||
@@ -762,7 +763,7 @@ ResponseParser::SetLiteralHandler(LiteralHandler* handler)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
ResponseParser::NextResponse(Response& response, bigtime_t timeout)
|
ResponseParser::NextResponse(Response& response, bigtime_t timeout)
|
||||||
throw(ParseException)
|
throw(ParseException, StreamException)
|
||||||
{
|
{
|
||||||
response.Parse(*fStream, fLiteralHandler);
|
response.Parse(*fStream, fLiteralHandler);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
~Response();
|
~Response();
|
||||||
|
|
||||||
void Parse(BDataIO& stream, LiteralHandler* handler)
|
void Parse(BDataIO& stream, LiteralHandler* handler)
|
||||||
throw(ParseException);
|
throw(ParseException, StreamException);
|
||||||
|
|
||||||
bool IsUntagged() const { return fTag == 0; }
|
bool IsUntagged() const { return fTag == 0; }
|
||||||
uint32 Tag() const { return fTag; }
|
uint32 Tag() const { return fTag; }
|
||||||
@@ -194,7 +194,8 @@ public:
|
|||||||
void SetLiteralHandler(LiteralHandler* handler);
|
void SetLiteralHandler(LiteralHandler* handler);
|
||||||
|
|
||||||
status_t NextResponse(Response& response,
|
status_t NextResponse(Response& response,
|
||||||
bigtime_t timeout) throw(ParseException);
|
bigtime_t timeout)
|
||||||
|
throw(ParseException, StreamException);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResponseParser(const ResponseParser& other);
|
ResponseParser(const ResponseParser& other);
|
||||||
|
|||||||
Reference in New Issue
Block a user