RFR: 8282038: CipherSpi.bufferCrypt leaves plaintext copy on the heap

2022-06-14 Thread Weijun Wang
Clearing buffers and temporary arrays to avoid data leaks in cipher operations.

-

Commit messages:
 - the fix

Changes: https://git.openjdk.org/jdk/pull/9158/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk=9158=00
  Issue: https://bugs.openjdk.org/browse/JDK-8282038
  Stats: 49 lines in 3 files changed: 25 ins; 12 del; 12 mod
  Patch: https://git.openjdk.org/jdk/pull/9158.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9158/head:pull/9158

PR: https://git.openjdk.org/jdk/pull/9158


RFR: 8220732: setSeed(long) java api doc is missing warning about provided seed quality

2022-06-14 Thread Kevin Driver
Resolves 
[JDK-8220732](https://bugs.openjdk.org/browse/JDK-8220732?filter=42718). The 
additional guidance as been added to the javadoc for `setSeed(long)`

-

Commit messages:
 - Resolves JDK-8220732. The additional guidance as been added to the javadoc 
for setSeed(long)

Changes: https://git.openjdk.org/jdk/pull/9156/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=9156=00
  Issue: https://bugs.openjdk.org/browse/JDK-8220732
  Stats: 5 lines in 1 file changed: 5 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/9156.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9156/head:pull/9156

PR: https://git.openjdk.org/jdk/pull/9156


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v4]

2022-06-14 Thread Alan Bateman
On Tue, 14 Jun 2022 12:18:52 GMT, Matthias Baesken  wrote:

>> When trying to construct an LdapURL object with a bad input string (in this 
>> example the _ in ad_jbs is causing issues), and not using
>> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we 
>> run into the exception below :
>> 
>> import com.sun.jndi.ldap.LdapURL;
>>  
>> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing 
>> _
>> LdapURL ldapUrl = new LdapURL(url);
>> 
>> 
>> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
>> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
>> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
>> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
>> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
>> Caused by: java.net.MalformedURLException: unsupported authority: 
>> ad_jbs.ttt.net:389
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
>> 
>> I would like to add the host and port info to the exception (in the example 
>> it is host:port of URI:null:-1] ) so that it is directly visible that the 
>> input caused the construction of a URI
>> with "special"/problematic host and port values.
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   avoid very long line

Marked as reviewed by alanb (Reviewer).

-

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v4]

2022-06-14 Thread Daniel Fuchs
On Tue, 14 Jun 2022 12:18:52 GMT, Matthias Baesken  wrote:

>> When trying to construct an LdapURL object with a bad input string (in this 
>> example the _ in ad_jbs is causing issues), and not using
>> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we 
>> run into the exception below :
>> 
>> import com.sun.jndi.ldap.LdapURL;
>>  
>> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing 
>> _
>> LdapURL ldapUrl = new LdapURL(url);
>> 
>> 
>> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
>> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
>> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
>> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
>> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
>> Caused by: java.net.MalformedURLException: unsupported authority: 
>> ad_jbs.ttt.net:389
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
>> 
>> I would like to add the host and port info to the exception (in the example 
>> it is host:port of URI:null:-1] ) so that it is directly visible that the 
>> input caused the construction of a URI
>> with "special"/problematic host and port values.
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   avoid very long line

The last changes LGTM.

-

Marked as reviewed by dfuchs (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v4]

2022-06-14 Thread Matthias Baesken
> When trying to construct an LdapURL object with a bad input string (in this 
> example the _ in ad_jbs is causing issues), and not using
> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we run 
> into the exception below :
> 
> import com.sun.jndi.ldap.LdapURL;
>  
> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing _
> LdapURL ldapUrl = new LdapURL(url);
> 
> 
> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
> Caused by: java.net.MalformedURLException: unsupported authority: 
> ad_jbs.ttt.net:389
> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
> 
> I would like to add the host and port info to the exception (in the example 
> it is host:port of URI:null:-1] ) so that it is directly visible that the 
> input caused the construction of a URI
> with "special"/problematic host and port values.

Matthias Baesken has updated the pull request incrementally with one additional 
commit since the last revision:

  avoid very long line

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/9126/files
  - new: https://git.openjdk.org/jdk/pull/9126/files/bdbe2204..8f528226

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=9126=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=9126=02-03

  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/9126.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9126/head:pull/9126

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v3]

2022-06-14 Thread Bernd Eckenfels
The change does not seem to be related to your description, and the description 
does not match the shown exception. In fact the example stacktrace contains the 
authority value twice and your change adds a diagnostic which is not really 
helpful for the case of the underscore? I would not be too specific for such 
general parsing rules.


--
http://bernd.eckenfels.net

Von: core-libs-dev  im Auftrag von 
Matthias Baesken 
Gesendet: Tuesday, June 14, 2022 1:36:36 PM
An: core-libs-...@openjdk.java.net ; 
security-dev@openjdk.java.net 
Betreff: Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat 
[v3]

> When trying to construct an LdapURL object with a bad input string (in this 
> example the _ in ad_jbs is causing issues), and not using
> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we run 
> into the exception below :
>
> import com.sun.jndi.ldap.LdapURL;
>  
> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing _
> LdapURL ldapUrl = new LdapURL(url);
>
>
> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
> Caused by: java.net.MalformedURLException: unsupported authority: 
> ad_jbs.ttt.net:389
> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
>
> I would like to add the host and port info to the exception (in the example 
> it is host:port of URI:null:-1] ) so that it is directly visible that the 
> input caused the construction of a URI
> with "special"/problematic host and port values.

Matthias Baesken has updated the pull request incrementally with one additional 
commit since the last revision:

  fix copy paste error

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/9126/files
  - new: https://git.openjdk.org/jdk/pull/9126/files/1050c724..bdbe2204

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=9126=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=9126=01-02

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/9126.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9126/head:pull/9126

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v3]

2022-06-14 Thread Alan Bateman
On Tue, 14 Jun 2022 11:36:36 GMT, Matthias Baesken  wrote:

>> When trying to construct an LdapURL object with a bad input string (in this 
>> example the _ in ad_jbs is causing issues), and not using
>> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we 
>> run into the exception below :
>> 
>> import com.sun.jndi.ldap.LdapURL;
>>  
>> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing 
>> _
>> LdapURL ldapUrl = new LdapURL(url);
>> 
>> 
>> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
>> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
>> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
>> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
>> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
>> Caused by: java.net.MalformedURLException: unsupported authority: 
>> ad_jbs.ttt.net:389
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
>> 
>> I would like to add the host and port info to the exception (in the example 
>> it is host:port of URI:null:-1] ) so that it is directly visible that the 
>> input caused the construction of a URI
>> with "special"/problematic host and port values.
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   fix copy paste error

src/java.naming/share/classes/com/sun/jndi/toolkit/url/Uri.java line 368:

> 366: // throw if we have user info or regname
> 367: throw new MalformedURLException("Authority 
> component is not server-based, or contains user info. Unsupported authority: 
> " + auth);
> 368: }

This looks okay but you may have to split up the line to avoid adding a 150+ 
char line (most of the file seems to keep the lines under 100 or so).

-

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v3]

2022-06-14 Thread Matthias Baesken
> When trying to construct an LdapURL object with a bad input string (in this 
> example the _ in ad_jbs is causing issues), and not using
> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we run 
> into the exception below :
> 
> import com.sun.jndi.ldap.LdapURL;
>  
> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing _
> LdapURL ldapUrl = new LdapURL(url);
> 
> 
> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
> Caused by: java.net.MalformedURLException: unsupported authority: 
> ad_jbs.ttt.net:389
> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
> 
> I would like to add the host and port info to the exception (in the example 
> it is host:port of URI:null:-1] ) so that it is directly visible that the 
> input caused the construction of a URI
> with "special"/problematic host and port values.

Matthias Baesken has updated the pull request incrementally with one additional 
commit since the last revision:

  fix copy paste error

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/9126/files
  - new: https://git.openjdk.org/jdk/pull/9126/files/1050c724..bdbe2204

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=9126=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=9126=01-02

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/9126.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9126/head:pull/9126

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v2]

2022-06-14 Thread Matthias Baesken
On Tue, 14 Jun 2022 10:43:54 GMT, Matthias Baesken  wrote:

>> When trying to construct an LdapURL object with a bad input string (in this 
>> example the _ in ad_jbs is causing issues), and not using
>> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we 
>> run into the exception below :
>> 
>> import com.sun.jndi.ldap.LdapURL;
>>  
>> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing 
>> _
>> LdapURL ldapUrl = new LdapURL(url);
>> 
>> 
>> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
>> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
>> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
>> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
>> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
>> Caused by: java.net.MalformedURLException: unsupported authority: 
>> ad_jbs.ttt.net:389
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
>> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
>> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
>> 
>> I would like to add the host and port info to the exception (in the example 
>> it is host:port of URI:null:-1] ) so that it is directly visible that the 
>> input caused the construction of a URI
>> with "special"/problematic host and port values.
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Adjust exception text to the suggestion of Daniel Fuchs

> I guess there's been some copy paste mistake here :-)

Yes, had to fix that!

-

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat [v2]

2022-06-14 Thread Matthias Baesken
> When trying to construct an LdapURL object with a bad input string (in this 
> example the _ in ad_jbs is causing issues), and not using
> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we run 
> into the exception below :
> 
> import com.sun.jndi.ldap.LdapURL;
>  
> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing _
> LdapURL ldapUrl = new LdapURL(url);
> 
> 
> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
> Caused by: java.net.MalformedURLException: unsupported authority: 
> ad_jbs.ttt.net:389
> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
> 
> I would like to add the host and port info to the exception (in the example 
> it is host:port of URI:null:-1] ) so that it is directly visible that the 
> input caused the construction of a URI
> with "special"/problematic host and port values.

Matthias Baesken has updated the pull request incrementally with one additional 
commit since the last revision:

  Adjust exception text to the suggestion of Daniel Fuchs

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/9126/files
  - new: https://git.openjdk.org/jdk/pull/9126/files/2454d4e5..1050c724

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=9126=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=9126=00-01

  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/9126.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9126/head:pull/9126

PR: https://git.openjdk.org/jdk/pull/9126


Re: RFR: JDK-8288207: Enhance MalformedURLException in Uri.parseCompat

2022-06-14 Thread Matthias Baesken
On Fri, 10 Jun 2022 12:16:17 GMT, Matthias Baesken  wrote:

> When trying to construct an LdapURL object with a bad input string (in this 
> example the _ in ad_jbs is causing issues), and not using
> the backward compatibility flag -Dcom.sun.jndi.ldapURLParsing="legacy" we run 
> into the exception below :
> 
> import com.sun.jndi.ldap.LdapURL;
>  
> String url = "ldap://ad_jbs.ttt.net:389/xyz;; // bad input string containing _
> LdapURL ldapUrl = new LdapURL(url);
> 
> 
> java --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED LdapParseUrlTest
> Exception in thread "main" javax.naming.NamingException: Cannot parse url: 
> ldap://ad_jbs.ttt.net:389/xyz [Root exception is 
> java.net.MalformedURLException: unsupported authority: ad_jbs.ttt.net:389]
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:115)
> at LdapParseUrlTest.main(LdapParseUrlTest.java:9)
> Caused by: java.net.MalformedURLException: unsupported authority: 
> ad_jbs.ttt.net:389
> at java.naming/com.sun.jndi.toolkit.url.Uri.parseCompat(Uri.java:367)
> at java.naming/com.sun.jndi.toolkit.url.Uri.parse(Uri.java:230)
> at java.naming/com.sun.jndi.toolkit.url.Uri.init(Uri.java:174)
> at java.naming/com.sun.jndi.ldap.LdapURL.(LdapURL.java:105)
> 
> I would like to add the host and port info to the exception (in the example 
> it is host:port of URI:null:-1] ) so that it is directly visible that the 
> input caused the construction of a URI
> with "special"/problematic host and port values.

Thanks Daniel, I adjusted the exception message to what you suggested.

-

PR: https://git.openjdk.org/jdk/pull/9126