diff --git a/jdk/make/lib/Lib-java.management.gmk b/jdk/make/lib/Lib-java.management.gmk index 9f4435d7707..e0e6f1d9476 100644 --- a/jdk/make/lib/Lib-java.management.gmk +++ b/jdk/make/lib/Lib-java.management.gmk @@ -38,6 +38,11 @@ BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/i $(LIBJAVA_HEADER_FLAGS) \ # +# In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate +# a binary that is compatible with windows versions older than 7/2008R2. +# See MSDN documentation for GetProcessMemoryInfo for more information. +BUILD_LIBMANAGEMENT_CFLAGS += -DPSAPI_VERSION=1 + BUILD_LIBMANAGEMENT_EXCLUDES := ifneq ($(OPENJDK_TARGET_OS), solaris) diff --git a/jdk/src/java.base/share/classes/java/util/BitSet.java b/jdk/src/java.base/share/classes/java/util/BitSet.java index 901a5a75800..f444072a185 100644 --- a/jdk/src/java.base/share/classes/java/util/BitSet.java +++ b/jdk/src/java.base/share/classes/java/util/BitSet.java @@ -1229,7 +1229,7 @@ public class BitSet implements Cloneable, java.io.Serializable { public int nextInt() { if (next != -1) { int ret = next; - next = nextSetBit(next+1); + next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1); return ret; } else { throw new NoSuchElementException(); diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java index b61e334c131..aa93bcb368d 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java @@ -481,6 +481,8 @@ class ZipEntry implements ZipConstants, Cloneable { } break; case EXTID_NTFS: + if (sz < 32) // reserved 4 bytes + tag 2 bytes + size 2 bytes + break; // m[a|c]time 24 bytes int pos = off + 4; // reserved 4 bytes if (get16(extra, pos) != 0x0001 || get16(extra, pos + 2) != 24) break; diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index 691ce46078f..9c8bc81393a 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java @@ -25,7 +25,11 @@ package javax.crypto; -import java.io.*; +import java.io.InputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; /** * A CipherInputStream is composed of an InputStream and a Cipher so @@ -88,8 +92,6 @@ public class CipherInputStream extends FilterInputStream { private int ofinish = 0; // stream status private boolean closed = false; - // The stream has been read from. False if the stream has never been read. - private boolean read = false; /** * private convenience function. @@ -101,11 +103,15 @@ public class CipherInputStream extends FilterInputStream { * return (ofinish-ostart) (we have this many bytes for you) * return 0 (no data now, but could have more later) * return -1 (absolutely no more data) + * + * Note: Exceptions are only thrown after the stream is completely read. + * For AEAD ciphers a read() of any length will internally cause the + * whole stream to be read fully and verify the authentication tag before + * returning decrypted data or exceptions. */ private int getMoreData() throws IOException { if (done) return -1; int readin = input.read(ibuffer); - read = true; if (readin == -1) { done = true; try { @@ -301,17 +307,16 @@ public class CipherInputStream extends FilterInputStream { closed = true; input.close(); - try { - // throw away the unprocessed data - if (!done) { + + // Throw away the unprocessed data and throw no crypto exceptions. + // AEAD ciphers are fully readed before closing. Any authentication + // exceptions would occur while reading. + if (!done) { + try { cipher.doFinal(); } - } - catch (BadPaddingException | IllegalBlockSizeException ex) { - /* If no data has been read from the stream to be en/decrypted, - we supress any exceptions, and close quietly. */ - if (read) { - throw new IOException(ex); + catch (BadPaddingException | IllegalBlockSizeException ex) { + // Catch exceptions as the rest of the stream is unused. } } ostart = 0; diff --git a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java index 2463102b266..6ed9a4e3f2c 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java @@ -322,7 +322,7 @@ public abstract class Policy { * in conjunction with the provided * {@code CodeSource}, determines the Permissions * returned by this method. This parameter - * may be {@code null}.

+ * may be {@code null}. * * @param cs the code specified by its {@code CodeSource} * that determines, in conjunction with the provided diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java index 8c55da5fa98..63336da2e78 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,7 +104,7 @@ import java.io.OutputStream; * operations on the GSSContext object are presented, * including: object instantiation, setting of desired flags, context * establishment, query of actual context flags, per-message operations on - * application data, and finally context deletion.

+ * application data, and finally context deletion. * *

  *    // Create a context using default credentials
@@ -209,7 +209,7 @@ public interface GSSContext {
      * Some mechanism providers might require that the caller be granted
      * permission to initiate a security context. A failed permission check
      * might cause a {@link java.lang.SecurityException SecurityException}
-     * to be thrown from this method.

+ * to be thrown from this method. * * @return a byte[] containing the token to be sent to the * peer. null indicates that no token is generated. @@ -276,7 +276,7 @@ public interface GSSContext { * to be thrown from this method.

* * The following example code demonstrates how this method might be - * used:

+ * used: *

      *     InputStream is ...
      *     OutputStream os ...
@@ -346,7 +346,7 @@ public interface GSSContext {
      * to be thrown from this method.

* * The following example code demonstrates how this method might be - * used:

+ * used: *

      *     byte[] inToken;
      *     byte[] outToken;
@@ -423,7 +423,7 @@ public interface GSSContext {
      * to be thrown from this method.

* * The following example code demonstrates how this method might be - * used:

+ * used: *

      *     InputStream is ...
      *     OutputStream os ...
@@ -510,7 +510,7 @@ public interface GSSContext {
      * GSS-API implementations are recommended but not required to detect
      * invalid QOP values when getWrapSizeLimit is called.
      * This routine guarantees only a maximum message size, not the
-     * availability of specific QOP values for message protection.

+ * availability of specific QOP values for message protection. * * @param qop the level of protection wrap will be asked to provide. * @param confReq true if wrap will be asked to provide @@ -595,7 +595,7 @@ public interface GSSContext { * * Since some application-level protocols may wish to use tokens * emitted by wrap to provide "secure framing", implementations should - * support the wrapping of zero-length messages.

+ * support the wrapping of zero-length messages. * * @param inStream an InputStream containing the application data to be * protected. All of the data that is available in @@ -630,7 +630,7 @@ public interface GSSContext { * * Since some application-level protocols may wish to use tokens * emitted by wrap to provide "secure framing", implementations should - * support the wrapping and unwrapping of zero-length messages.

+ * support the wrapping and unwrapping of zero-length messages. * * @param inBuf a byte array containing the wrap token received from * peer. @@ -679,7 +679,7 @@ public interface GSSContext { * * Other than the possible blocking behavior described above, this * method is equivalent to the byte array based {@link #unwrap(byte[], - * int, int, MessageProp) unwrap} method.

+ * int, int, MessageProp) unwrap} method. * * @param inStream an InputStream that contains the wrap token generated * by the peer. @@ -827,7 +827,7 @@ public interface GSSContext { * * Other than the possible blocking behavior described above, this * method is equivalent to the byte array based {@link #verifyMIC(byte[], - * int, int, byte[], int, int, MessageProp) verifyMIC} method.

+ * int, int, byte[], int, int, MessageProp) verifyMIC} method. * * @param tokStream an InputStream containing the token generated by the * peer's getMIC method. @@ -913,7 +913,7 @@ public interface GSSContext { * might require mutual authentication even if the application * doesn't. Therefore, the application should check to see if the * request was honored with the {@link #getMutualAuthState() - * getMutualAuthState} method.

+ * getMutualAuthState} method. * * @param state a boolean value indicating whether mutual * authentication should be used or not. @@ -943,7 +943,7 @@ public interface GSSContext { * MessageProp#isOldToken() MessageProp.isOldToken} methods will return * valid results for the MessageProp object that is passed * in to the unwrap method or the verifyMIC - * method.

+ * method. * * @param state a boolean value indicating whether replay detection * should be enabled over the established context or not. @@ -975,7 +975,7 @@ public interface GSSContext { * {@link MessageProp#isGapToken() MessageProp.isGapToken} methods will return * valid results for the MessageProp object that is passed * in to the unwrap method or the verifyMIC - * method.

+ * method. * * @param state a boolean value indicating whether sequence checking * should be enabled over the established context or not. @@ -1001,7 +1001,7 @@ public interface GSSContext { * delegation must not be used, then the mechanism will honor the * request and delegation will not occur. This is an exception * to the general rule that a mechanism may enable a service even if it - * is not requested.

+ * is not requested. * * @param state a boolean value indicating whether the credentials * should be delegated or not. @@ -1021,7 +1021,7 @@ public interface GSSContext { * * Not all mechanisms support anonymity for the initiator. Therefore, the * application should check to see if the request was honored with the - * {@link #getAnonymityState() getAnonymityState} method.

+ * {@link #getAnonymityState() getAnonymityState} method. * * @param state a boolean value indicating if the initiator should * be authenticated to the acceptor as an anonymous principal. @@ -1048,7 +1048,7 @@ public interface GSSContext { * object that is passed in to the wrap method.

* * Enabling confidentiality will also automatically enable - * integrity.

+ * integrity. * * @param state a boolean value indicating whether confidentiality * should be enabled or not. @@ -1075,7 +1075,7 @@ public interface GSSContext { * the {@link #getIntegState() getIntegState} method.

* * Disabling integrity will also automatically disable - * confidentiality.

+ * confidentiality. * * @param state a boolean value indicating whether integrity * should be enabled or not. @@ -1095,7 +1095,7 @@ public interface GSSContext { * * The actual lifetime of the context will depend on the capabilities of * the underlying mechanism and the application should call the {@link - * #getLifetime() getLifetime} method to determine this.

+ * #getLifetime() getLifetime} method to determine this. * * @param lifetime the desired context lifetime in seconds. Use * INDEFINITE_LIFETIME to request an indefinite lifetime @@ -1133,7 +1133,7 @@ public interface GSSContext { * initiator requests that delegation not be allowed the {@link * #requestCredDeleg(boolean) requestCredDeleg} method will honor that * request and this method will return false on the - * initiator's side from that point onwards.

+ * initiator's side from that point onwards. * * @return true if delegation is enabled, false otherwise. * @see #requestCredDeleg(boolean) @@ -1147,7 +1147,7 @@ public interface GSSContext { * called only after context establishment is complete. An initiator * that requests mutual authentication can call this method after * context completion and dispose the context if its request was not - * honored.

+ * honored. * * @return true if mutual authentication is enabled, false otherwise. * @see #requestMutualAuth(boolean) @@ -1161,7 +1161,7 @@ public interface GSSContext { * definitive answer this method must be called only after context * establishment is complete. An initiator that requests replay * detection can call this method after context completion and - * dispose the context if its request was not honored.

+ * dispose the context if its request was not honored. * * @return true if replay detection is enabled, false otherwise. * @see #requestReplayDet(boolean) @@ -1175,7 +1175,7 @@ public interface GSSContext { * definitive answer this method must be called only after context * establishment is complete. An initiator that requests sequence * checking can call this method after context completion and - * dispose the context if its request was not honored.

+ * dispose the context if its request was not honored. * * @return true if sequence checking is enabled, false otherwise. * @see #requestSequenceDet(boolean) @@ -1195,7 +1195,7 @@ public interface GSSContext { * should be sent to the peer or the context aborted. On the * acceptor side, a call to this method determines if any of the tokens * processed by acceptSecContext thus far have divulged - * the identity of the initiator.

+ * the identity of the initiator. * * @return true if the context initiator is still anonymous, false * otherwise. @@ -1235,7 +1235,7 @@ public interface GSSContext { * #isProtReady() isProtReady} or {@link #isEstablished() * isEstablished} return true. If this method returns * true, so will {@link #getIntegState() - * getIntegState}

+ * getIntegState} * * @return true if confidentiality services are available, false * otherwise. @@ -1250,7 +1250,7 @@ public interface GSSContext { * #isProtReady() isProtReady} or {@link #isEstablished() * isEstablished} return true. This method will always * return true if {@link #getConfState() getConfState} - * returns true.

+ * returns true. * * @return true if integrity services are available, false otherwise. * @see #requestInteg(boolean) @@ -1262,7 +1262,7 @@ public interface GSSContext { * context is. It can be called by both the context initiator and the * context acceptor, but for a definitive answer it should be called * only after {@link #isEstablished() isEstablished} returns - * true.

+ * true. * * @return the remaining lifetime in seconds * @see #requestLifetime(int) diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java index fbe379ef2e6..115ee74a41b 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ package org.ietf.jgss; * * This example code demonstrates the creation of a GSSCredential * implementation for a specific entity, querying of its fields, and its - * release when it is no longer needed:

+ * release when it is no longer needed: *

  *    GSSManager manager = GSSManager.getInstance();
  *
diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
index cfde0e58fe2..ed7e3ad6332 100644
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@ package org.ietf.jgss;
  * mechanism implementation is responsible for setting appropriate minor
  * status codes when throwing this exception.  Aside from delivering the
  * numeric error codes to the caller, this class performs the mapping from
- * their numeric values to textual representations. 

+ * their numeric values to textual representations. * * @author Mayank Upadhyay * @since 1.4 diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java index 3bf99e409ab..f9ae3efafee 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ import java.security.Provider; * of this and recover cleanly by catching the exception.

* * It is envisioned that there will be three most common ways in which - * providers will be used:

+ * providers will be used: *

    *
  1. The application does not care about what provider is used (the * default case). @@ -87,7 +87,7 @@ import java.security.Provider; * the addProviderAtFront method on a GSSManager that has * already created an object.

    * - * Here is some sample code showing how the GSSManager might be used:

    + * Here is some sample code showing how the GSSManager might be used: *

      *     GSSManager manager = GSSManager.getInstance();
      *
    @@ -116,7 +116,7 @@ import java.security.Provider;
      *                                                GSSContext.DEFAULT_LIFETIME);
      * 

    * - * The server side might use the following variation of this source:

    + * The server side might use the following variation of this source: * *

      *     // Acquire credentials for the server
    @@ -387,7 +387,7 @@ public abstract class GSSManager {
          * Non-default values for lifetime cannot always be honored by the
          * underlying mechanisms, thus applications should be prepared to call
          * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
    -     * on the returned credential.

    + * on the returned credential. * * @param name the name of the principal for whom this credential is to be * acquired. Use null to specify the default principal. @@ -442,7 +442,7 @@ public abstract class GSSManager { * Non-default values for lifetime cannot always be honored by the * underlying mechanisms, thus applications should be prepared to call * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime} - * on the returned credential.

    + * on the returned credential. * * @param name the name of the principal for whom this credential is to * be acquired. Use null to specify the default @@ -492,7 +492,7 @@ public abstract class GSSManager { * Non-default values for lifetime cannot always be honored by the * underlying mechanism, thus applications should be prepared to call * {@link GSSContext#getLifetime() getLifetime} on the returned - * context.

    + * context. * * @param peer the name of the target peer. * @param mech the Oid of the desired mechanism. Use null @@ -610,7 +610,7 @@ public abstract class GSSManager { * operation is unavailable.

    * * Suppose an application desired that the provider A always be checked - * first when any mechanism is needed, it would call:

    + * first when any mechanism is needed, it would call: *

          *         GSSManager mgr = GSSManager.getInstance();
          *         // mgr may at this point have its own pre-configured list
    @@ -621,7 +621,7 @@ public abstract class GSSManager {
          * 
    * Now if it also desired that the mechanism of Oid m1 always be * obtained from the provider B before the previously set A was checked, - * it would call:

    + * it would call: *

          *         mgr.addProviderAtFront(B, m1);
          * 
    @@ -632,7 +632,7 @@ public abstract class GSSManager { * directly.

    * * Suppose at a later time the following call is made to the same - * GSSManager instance:

    + * GSSManager instance: *

          *         mgr.addProviderAtFront(B, null)
          * 
    @@ -684,14 +684,14 @@ public abstract class GSSManager { * Suppose an application desired that when a mechanism of Oid m1 is * needed the system default providers always be checked first, and only * when they do not support m1 should a provider A be checked. It would - * then make the call:

    + * then make the call: *

          *         GSSManager mgr = GSSManager.getInstance();
          *         mgr.addProviderAtEnd(A, m1);
          * 
    * Now, if it also desired that for all mechanisms the provider B be * checked after all configured providers have been checked, it would - * then call:

    + * then call: *

          *         mgr.addProviderAtEnd(B, null);
          * 
    @@ -699,7 +699,7 @@ public abstract class GSSManager { * null)}.

    * * Suppose at a later time the following call is made to the same - * GSSManager instance:

    + * GSSManager instance: *

          *         mgr.addProviderAtEnd(B, m2)
          * 
    @@ -708,7 +708,7 @@ public abstract class GSSManager { * request is made for the already existing pairs of (A, m1) or (B, * null).

    * - * Please note, however, that the following call:

    + * Please note, however, that the following call: *

          *         mgr.addProviderAtEnd(A, null)
          * 
    diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java index 580ab39383a..185a6c2f7b4 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ package org.ietf.jgss; * The code below creates a GSSName, converts it to an MN, performs a * comparison, obtains a printable representation of the name, exports it * to a byte array and then re-imports to obtain a - * new GSSName.

    + * new GSSName. *

      *      GSSManager manager = GSSManager.getInstance();
      *
    @@ -236,7 +236,8 @@ public interface GSSName {
          * method {@link GSSManager#createName(byte[], Oid)
          * GSSManager.createName} and specifying the NT_EXPORT_NAME as the name
          * type object identifier. The resulting GSSName name will
    -     * also be a MN.

    + * also be a MN. + * * @return a byte[] containing the exported name. RFC 2743 defines the * "Mechanism-Independent Exported Name Object Format" for these bytes. * diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java index 2f776ebc2e6..8568f57ef11 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ package org.ietf.jgss; * false. Upon return from these methods, this object will also * contain any supplementary status values applicable to the processed * token. The supplementary status values can indicate old tokens, out - * of sequence tokens, gap tokens or duplicate tokens.

    + * of sequence tokens, gap tokens or duplicate tokens. * * @see GSSContext#wrap * @see GSSContext#unwrap diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html index 1dc1ec4985b..2049a263abe 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html @@ -2,7 +2,7 @@