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

jdwp library loader in linker_md.c quietly truncates on buffer overflow

    Details

    • Subcomponent:
    • Resolved In Build:
      b15

      Backports

        Description

        Known bug (documented in code comment) quietly truncates when the buffer length is less than the path string plus the length of the file name (plus 10).

        This is a problem for three main reasons:
        1) This should be an error. It isn't one.
        2) The current form outputs no useful debug information.
        3) The path string can contain multiple paths, and we act based on the length *before* chopping it into individual paths. So if we have two strings of length: 300, and a maximum buffer size of 400, we act as if there's something wrong.

        To solve all three issues, I've created a webrev with a fix.

        IMPORTANT NOTE: the os.cpp change is only to enable testing. This will NOT be included in the final webrev. I added the os.cpp bit because right now the parameter that provokes a failure in the dll_build_name function (the one that handles multiple paths) causes failure in os.cpp when it loads libraries during startup. Still changing dll_build_name because I don't think we should be relying on os.cpp behaviour.

        Testing:

        Step 1: Apply changes and build
        Step 2: export LONGPATH="/aaaaaaa" (continue aaaaas for 5000 characters)
        Step 3: rename the libdtsocket.so file to something else, or just move it.
        This means that the relevant code won't find the library in the default path, and will iterate through alternate paths to find it.
        Step 4: Run this to test the fix: java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n -Dsun.boot.library.path=$LONGPATH TestClass
        (Where TestClass does nothing. Can print a message to show it ran.)
        Step 5: watch as new, useful error message is produced.

        Webrev: http://cr.openjdk.java.net/~afarley/8229378/webrev/

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  afarley Adam Farley
                  Reporter:
                  afarley Adam Farley
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: