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

GCC 12 reports use-after-free potential bugs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 19
    • Fix Version/s: 19
    • Component/s: core-libs
    • Labels:
      None
    • Resolved In Build:
      b23

      Description

      GCC 12 reports use-after-free potential bugs in below:

      ```
      In function 'find_positions',
          inlined from 'find_file' at /home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/parse_manifest.c:364:9:
      /home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/parse_manifest.c:292:34: warning: pointer 'endpos' used after 'free' [-Wuse-after-free]
        292 | pos = flen - (endpos - cp);
            | ~~~~~~~~^~~~~
      /home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/parse_manifest.c:291:13: note: call to 'free' here
        291 | free(buffer);
            | ^~~~~~~~~~~~
      Updating jdk/modules/jdk.jpackage/jdk/jpackage/internal/resources/jpackageapplauncher due to 1 file(s)
      /home/ysuenaga/github-forked/jdk/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c: In function 'popenCommand':
      /home/ysuenaga/github-forked/jdk/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c:180:63: warning: pointer 'strBufBegin' may be used after 'realloc' [-Wuse-after-free]
        180 | strBufNextChar = strNewBufBegin + (strBufNextChar - strBufBegin);
            | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      /home/ysuenaga/github-forked/jdk/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c:174:30: note: call to 'realloc' here
        174 | strNewBufBegin = realloc(strBufBegin, strBufCapacity);
            | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ```

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ysuenaga Yasumasa Suenaga
              Reporter:
              ysuenaga Yasumasa Suenaga
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: