8240848: ArrayIndexOutOfBoundsException buf for TextCallbackHandler

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2020-04-10 15:05:42 +08:00
parent 592b9a9571
commit 502d45955f
2 changed files with 25 additions and 11 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, 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
@ -35,7 +35,6 @@ import javax.security.auth.callback.UnsupportedCallbackException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
@ -236,8 +235,9 @@ public class ConsoleCallbackHandler implements CallbackHandler {
result = Integer.parseInt(readLine());
if (result < 0 || result > (options.length - 1)) {
result = defaultOption;
} else {
result = options[result].value;
}
result = options[result].value;
} catch (NumberFormatException e) {
result = defaultOption;
}