8303669: SelectVersion indexes past the end of the argv array
Reviewed-by: vromero
This commit is contained in:
parent
25868b95ee
commit
fa14314853
@ -1007,7 +1007,7 @@ SelectVersion(int argc, char **argv, char **main_class)
|
|||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
while ((arg = *argv) != 0 && *arg == '-') {
|
while (argc > 0 && *(arg = *argv) == '-') {
|
||||||
has_arg = IsOptionWithArgument(argc, argv);
|
has_arg = IsOptionWithArgument(argc, argv);
|
||||||
if (JLI_StrCCmp(arg, "-version:") == 0) {
|
if (JLI_StrCCmp(arg, "-version:") == 0) {
|
||||||
JLI_ReportErrorMessage(SPC_ERROR1);
|
JLI_ReportErrorMessage(SPC_ERROR1);
|
||||||
@ -1209,7 +1209,7 @@ ParseArguments(int *pargc, char ***pargv,
|
|||||||
|
|
||||||
*pret = 0;
|
*pret = 0;
|
||||||
|
|
||||||
while ((arg = *argv) != 0 && *arg == '-') {
|
while (argc > 0 && *(arg = *argv) == '-') {
|
||||||
char *option = NULL;
|
char *option = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int kind = GetOpt(&argc, &argv, &option, &value);
|
int kind = GetOpt(&argc, &argv, &option, &value);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 8213362 8238225
|
* @bug 8213362 8238225 8303669
|
||||||
* @comment Test JLI_Launch for tools distributed outside JDK
|
* @comment Test JLI_Launch for tools distributed outside JDK
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @run main/native JliLaunchTest
|
* @run main/native JliLaunchTest
|
||||||
|
@ -33,8 +33,14 @@
|
|||||||
#include "java.h"
|
#include "java.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **args)
|
||||||
{
|
{
|
||||||
|
//avoid null-terminated array of arguments to test JDK-8303669
|
||||||
|
char *argv[argc];
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
argv[i] = args[i];
|
||||||
|
}
|
||||||
|
|
||||||
return JLI_Launch(argc, argv,
|
return JLI_Launch(argc, argv,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user