[PATCH] Bugfixes for gnu.mail.util.RFC2822OutputStream

Gary Benson <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
Hi,

The attached patch fixes a couple of bugs in RFC2822OutputStream.
Firstly, there was an off-by-one error which meant that the last byte
of each write() was lost if the array being written contained a
carriage return or a linefeed.  Secondly, long lines were not split
correctly.

Cheers,
Gary

[ [email protected] ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]

_______________________________________________
Classpathx-javamail mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/classpathx-javamail
javamail-20031006-rfc2822.patch (text/plain, 1 KB)
Fix an off-by-one bug which caused the last byte written to be lost if
there was a CR or LF in the array, and fix a bug where long lines were
not properly split.

Index: RFC2822OutputStream.java
===================================================================
RCS file: /cvs/rhug/rhug/classpathx-mail/upstream/source/gnu/mail/util/RFC2822OutputStream.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 RFC2822OutputStream.java
--- upstream/source/gnu/mail/util/RFC2822OutputStream.java	15 Oct 2003 15:39:48 -0000	1.1.1.1
+++ upstream/source/gnu/mail/util/RFC2822OutputStream.java	23 Oct 2003 15:13:15 -0000
@@ -117,17 +117,17 @@
       count++;
       if (b[i]==CR || b[i]==LF)
       {
-        out.write(b, d, i-d);
-        d = i;
+        out.write(b, d, i+1-d);
+        d = i + 1;
         count = 0;
       }
       else
       {
         if (count>998)
         {
-          out.write(LF);
           out.write(b, d, count);
-          d = i;
+          out.write(LF);
+          d = i + 1;
           count = 0;
         }
       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.