Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286694

Incorrect argument processing in java launcher

    XMLWordPrintable

Details

    • b24

    Backports

      Description

        GCC 12 reports as following:

        ```
        /home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/java.c:1629:35: error: the comparison will always evaluate as 'false' for the pointer operand in 'arg + 2' must not be NULL [-Werror=address]
         1629 | *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2);
              |
        ```

        The code is here:

        ```
        1625 /* Copy the VM arguments (i.e. prefixed with -J) */
        1626 for (i = 0; i < jargc; i++) {
        1627 const char *arg = jargv[i];
        1628 if (arg[0] == '-' && arg[1] == 'J') {
        1629 *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(a rg + 2);
        1630 }
        1631 }
        ```

        It seems to be expected that `NULL` is set to new array for arguments if invalid parameter ( `-J` only) is passed.
        However `NULL` in new array for arguments (`nargv`) means stop condition for argument processing in below:

        ```
        1214 while ((arg = *argv) != 0 && *arg == '-') {
        ```

        `jargv` in L1627 means builtin arguments which is defined by `JAVA_ARGS` or `EXTRA_JAVA_ARGS` macro. So it should be ignored and reported it in laucher trace log.

        Attachments

          Issue Links

            Activity

              People

                ysuenaga Yasumasa Suenaga
                ysuenaga Yasumasa Suenaga
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: