Skip to content
Permalink
Browse files
8262199: issue in jli args.c
Reviewed-by: clanger, alanb
  • Loading branch information
MBaesken committed Feb 26, 2021
1 parent 7603278 commit d7efb4cc35a7c4a2d084ed865519cbb40eeb6d51
Showing with 10 additions and 17 deletions.
  1. +10 −17 src/java.base/share/native/libjli/args.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -360,36 +360,29 @@ static JLI_List readArgFile(FILE *file) {
* otherwise, return NULL.
*/
static JLI_List expandArgFile(const char *arg) {
FILE *fptr;
struct stat st;
JLI_List rv;
struct stat st;
FILE *fptr = fopen(arg, "r");

/* failed to access the file */
if (stat(arg, &st) != 0) {
JLI_ReportMessage(CFG_ERROR6, arg);
exit(1);
}

if (st.st_size > MAX_ARGF_SIZE) {
JLI_ReportMessage(CFG_ERROR10, MAX_ARGF_SIZE);
exit(1);
}

fptr = fopen(arg, "r");
/* arg file cannot be openned */
if (fptr == NULL) {
if (fptr == NULL || fstat(fileno(fptr), &st) != 0) {
JLI_ReportMessage(CFG_ERROR6, arg);
exit(1);
} else {
if (st.st_size > MAX_ARGF_SIZE) {
JLI_ReportMessage(CFG_ERROR10, MAX_ARGF_SIZE);
exit(1);
}
}

rv = readArgFile(fptr);
fclose(fptr);

/* error occurred reading the file */
if (rv == NULL) {
JLI_ReportMessage(DLL_ERROR4, arg);
exit(1);
}
fclose(fptr);

return rv;
}

1 comment on commit d7efb4c

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on d7efb4c Feb 26, 2021

Please sign in to comment.