8262199: issue in jli args.c

Reviewed-by: clanger, alanb
This commit is contained in:
Matthias Baesken 2021-02-26 11:21:26 +00:00
parent 7603278164
commit d7efb4cc35

View file

@ -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;
}