RFR: JDK-8262199: issue in jli args.c [v3]

Christoph Langer clanger at openjdk.java.net
Thu Feb 25 16:12:40 UTC 2021


On Thu, 25 Feb 2021 15:40:00 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> Sonar reports a finding in args.c, where a file check is done .
>> Stat performs a check on file, and later fopen is called on the file .
>> 
>> The coding could be slightly rewritten so that the potential issue is removed (however I do not think that it is such a big issue).
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove fclose before exit

Changes requested by clanger (Reviewer).

src/java.base/share/native/libjli/args.c line 378:

> 376:         if (st.st_size > MAX_ARGF_SIZE) {
> 377:             JLI_ReportMessage(CFG_ERROR10, MAX_ARGF_SIZE);
> 378:             reportAndExit(NULL, NULL);

This should be just one statement,
    reportAndExit(CFG_ERROR10, MAX_ARGF_SIZE);
or?

src/java.base/share/native/libjli/args.c line 358:

> 356: 
> 357: static void reportAndExit(const char* fmt, const char* arg) {
> 358:     if (fmt != NULL) JLI_ReportMessage(fmt, arg);

the if (fmt != NULL) check wouldn't be necessary here if you fix the other location with reportAndExit(NULL, NULL), I think

-------------

PR: https://git.openjdk.java.net/jdk/pull/2692


More information about the core-libs-dev mailing list