aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2006-11-17 22:57:48 +0000
committerVincent Richard <[email protected]>2006-11-17 22:57:48 +0000
commit8f7a3ab27a3393de7d475e67d09ab1b82eaa8013 (patch)
treed4ac13df0d7f2d2b434d203fead7e128cdf1b1ec
parentFixed indentation. (diff)
downloadvmime-8f7a3ab27a3393de7d475e67d09ab1b82eaa8013.tar.gz
vmime-8f7a3ab27a3393de7d475e67d09ab1b82eaa8013.zip
Fixed maximum line length bug.
-rw-r--r--src/encoderB64.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/encoderB64.cpp b/src/encoderB64.cpp
index 8ef788b6..0e8bbe30 100644
--- a/src/encoderB64.cpp
+++ b/src/encoderB64.cpp
@@ -117,13 +117,16 @@ const utility::stream::size_type encoderB64::encode(utility::inputStream& in,
while (count < 3 && bufferPos < bufferLength)
bytes[count++] = buffer[bufferPos++];
- if (count != 3)
+ while (count < 3)
{
// There may be more data in the next chunk...
if (bufferPos >= bufferLength)
{
bufferLength = in.read(buffer, sizeof(buffer));
bufferPos = 0;
+
+ if (bufferLength == 0)
+ break;
}
while (count < 3 && bufferPos < bufferLength)
@@ -169,7 +172,7 @@ const utility::stream::size_type encoderB64::encode(utility::inputStream& in,
total += 4;
curCol += 4;
- if (cutLines && curCol >= maxLineLength - 1)
+ if (cutLines && curCol >= maxLineLength - 2 /* \r\n */ - 4 /* next bytes */)
{
out.write("\r\n", 2);
curCol = 0;