8267860: Off-by-one bug when searching arrays in AlpnGreaseTest

Co-authored-by: Bradford Wetmore <wetmore@openjdk.org>
Reviewed-by: wetmore
This commit is contained in:
Kevin Driver 2022-06-13 14:38:36 +00:00 committed by Bradford Wetmore
parent 4aede33fbf
commit 2adef6a1f8

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, 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
@ -83,7 +83,7 @@ public class AlpnGreaseTest implements SSLContextTemplate {
new String(greaseBytes, StandardCharsets.ISO_8859_1);
private static void findGreaseInClientHello(byte[] bytes) throws Exception {
for (int i = 0; i < bytes.length - greaseBytes.length; i++) {
for (int i = 0; i < bytes.length - greaseBytes.length + 1; i++) {
if (Arrays.equals(bytes, i, i + greaseBytes.length,
greaseBytes, 0, greaseBytes.length)) {
System.out.println("Found greaseBytes in ClientHello at: " + i);