summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-11-02 14:56:08 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-11-02 14:56:08 (GMT)
commit74013991621ae5b688e7a71aefe759a6ec12cda5 (patch)
tree85ff0aa0d32cabeee43c1272d98914c8663cd7ea
parentc8665869aed8683ea579cc050f4527da02fd9b79 (diff)
downloadlibcalendaring-74013991621ae5b688e7a71aefe759a6ec12cda5.tar.gz
Fix ImapStreamParser CRLF skipping.
With the code before it was possible that either the carriage return or the newline was not yet parsed, resulting in it ending up as part of the payload. This resulted in broken payloads.
-rw-r--r--kimap/imapstreamparser.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/kimap/imapstreamparser.cpp b/kimap/imapstreamparser.cpp
index 50a8552..aa19a69 100644
--- a/kimap/imapstreamparser.cpp
+++ b/kimap/imapstreamparser.cpp
@@ -113,7 +113,10 @@ bool ImapStreamParser::hasLiteral()
m_literalSize = m_data.mid( m_position + 1, end - m_position - 1 ).toInt();
// strip CRLF
m_position = end + 1;
-
+ // ensure that the CRLF is available
+ if ( !waitForMoreData( m_position + 1 >= m_data.length() ) ) {
+ throw ImapParserException( "Unable to read more data" );
+ }
if ( m_position < m_data.length() && m_data.at(m_position) == '\r' )
++m_position;
if ( m_position < m_data.length() && m_data.at(m_position) == '\n' )