changeset 51037:2bafeb7a1f6b

8204494: Fix for 8200530 triggered regression, closed/test/jdk/security/infra/java/security/KeyStore/BouncyCastleInterop.java failed Reviewed-by: rriggs
author sherman
date Wed, 06 Jun 2018 14:36:48 -0700
parents 3a91f09a46be
children 505d944de3c5
files src/java.base/share/classes/java/util/jar/Manifest.java
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
                 }
             }