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

SetLibraryPath() deals with LD_LIBRARY_PATH incorrectly

XMLWordPrintable

    • generic, sparc
    • solaris_2.5.1, solaris_2.6

      Function SetLibraryPath in module src/solaris/java/jre/jre_md.c (JDK 113)
        retrieves the value of The logic in the function
      is backwards with respect to updating the value to include additional
      values. If LD_LIBRARY_PATH. is not set, the function attempts to do
      a strlen() and tries to append to it. If it is set, it basically
      overwrites it.

              /*
               * Sets LD_LIBRARY_PATH to include the specified directory.
               */
              void
              SetLibraryPath(const char *dir)
              {
                  char *s = getenv("LD_LIBRARY_PATH"), *buf;

                  /* Set library path */
                  if (s == 0) {
                      buf = JRE_Malloc(strlen(dir) + strlen(s) + 32);
                      sprintf(buf, "LD_LIBRARY_PATH=%s:%s", dir, s);
                  } else {
                      buf = JRE_Malloc(strlen(dir) + 32);
                              sprintf(buf, "LD_LIBRARY_PATH=%s", dir);
                  }
                  if (putenv(buf) != 0) {
                      perror("putenv");
                      exit(1);
                  }
              }

            dconnellsunw David Connelly (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: