[8u] RFR 8254631: Better support ALPN byte wire values in SunJSSE
Severin Gehwolf
sgehwolf at redhat.com
Wed May 26 16:00:36 UTC 2021
Hi Martin,
On Tue, 2021-05-18 at 12:06 -0400, Martin Balao wrote:
>
> Yes, I didn't put much thinking into this but you are right:
> performance can be improved. In that regard, looks to me that wrapping
> with a ByteBuffer may not be necessary when we consider the
> precondition that, inside the outer loop [1], 'bytes' array will be
> equal or greater than 'grease' array.
>
> Please have a look at this proposal:
>
> *
> http://cr.openjdk.java.net/~mbalao/webrevs/8254631/8254631.webrev.jdk8u.jdk.01/
I only now realize that there is an off-by-one error in the original
code:
+ private static void findGreaseInClientHello(byte[] bytes) throws Exception {
+ for (int i = 0; i < bytes.length - greaseBytes.length; i++) {
+ if (Arrays.equals(bytes, i, i + greaseBytes.length,
+ greaseBytes, 0, greaseBytes.length)) {
Should be:
+ private static void findGreaseInClientHello(byte[] bytes) throws Exception {
+ for (int i = 0; i < bytes.length - greaseBytes.length + 1; i++) {
+ if (Arrays.equals(bytes, i, i + greaseBytes.length,
+ greaseBytes, 0, greaseBytes.length)) {
Otherwise the grease bytes wouldn't be found if they'd be at the end of
the client hello bytes. I don't think that's very likely, but we should
fix it anyway.
85 private static void findGreaseInClientHello(byte[] bytes) throws Exception {
86 for (int i = 0; i < bytes.length - greaseBytes.length + 1; i++) {
87 if (findGreaseInArray(bytes, i)) {
88 System.out.println("Found greaseBytes in ClientHello at: " + i);
89 return;
90 }
Perhaps we should file a bug for fixing it in later releases too.
I don't need to see another webrev for this. Reviewed.
Thanks,
Severin
More information about the jdk8u-dev
mailing list