8204494: Fix for 8200530 triggered regression, closed/test/jdk/security/infra/java/security/KeyStore/BouncyCastleInterop.java failed
authorsherman
Wed, 06 Jun 2018 14:36:48 -0700
changeset 50433 2bafeb7a1f6b
parent 50432 3a91f09a46be
child 50434 505d944de3c5
8204494: Fix for 8200530 triggered regression, closed/test/jdk/security/infra/java/security/KeyStore/BouncyCastleInterop.java failed Reviewed-by: rriggs
src/java.base/share/classes/java/util/jar/Manifest.java
--- a/src/java.base/share/classes/java/util/jar/Manifest.java	Wed Jun 06 17:10:37 2018 -0400
+++ b/src/java.base/share/classes/java/util/jar/Manifest.java	Wed Jun 06 14:36:48 2018 -0700
@@ -393,7 +393,27 @@
                 off += n;
                 total += n;
                 pos = tpos;
-                if (c == '\n' || c == '\r') {
+                c = tbuf[tpos-1];
+                if (c == '\n') {
+                    break;
+                }
+                if (c == '\r') {
+                    if (count == pos) {
+                        // try to see if there is a trailing LF
+                        fill();
+                        if (pos < count && tbuf[pos] == '\n') {
+                            if (total < len) {
+                                b[off++] = '\n';
+                                total++;
+                            } else {
+                                // we should always have big enough lbuf but
+                                // just in case we don't, replace the last CR
+                                // with LF.
+                                b[off - 1] = '\n';
+                            }
+                            pos++;
+                        }
+                    }
                     break;
                 }
             }