diff options
author | Vincent Richard <[email protected]> | 2006-11-17 22:57:48 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2006-11-17 22:57:48 +0000 |
commit | 8f7a3ab27a3393de7d475e67d09ab1b82eaa8013 (patch) | |
tree | d4ac13df0d7f2d2b434d203fead7e128cdf1b1ec | |
parent | Fixed indentation. (diff) | |
download | vmime-8f7a3ab27a3393de7d475e67d09ab1b82eaa8013.tar.gz vmime-8f7a3ab27a3393de7d475e67d09ab1b82eaa8013.zip |
Fixed maximum line length bug.
-rw-r--r-- | src/encoderB64.cpp | 7 |
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; |